mirror of
https://github.com/JosunLP/BrowserExtensionTemplate.git
synced 2025-10-15 00:20:10 +00:00
basic structure
This commit is contained in:
parent
455c62a936
commit
977831157f
22 changed files with 1363 additions and 1 deletions
47
tools/deploy.ts
Normal file
47
tools/deploy.ts
Normal file
|
@ -0,0 +1,47 @@
|
|||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var DEPLOY_ENTRY = "./public";
|
||||
var DEPLOY_TARGET = "./dist";
|
||||
|
||||
function deleteFolderRecursive(path: string) {
|
||||
if (fs.existsSync(path)) {
|
||||
fs.readdirSync(path).forEach(function(file: string) {
|
||||
var curPath = path + "/" + file;
|
||||
if (fs.lstatSync(curPath).isDirectory()) {
|
||||
deleteFolderRecursive(curPath);
|
||||
} else {
|
||||
fs.unlinkSync(curPath);
|
||||
}
|
||||
});
|
||||
fs.rmdirSync(path);
|
||||
}
|
||||
}
|
||||
|
||||
function mkdirSync(path: string) {
|
||||
try {
|
||||
fs.mkdirSync(path);
|
||||
} catch(e: any) {
|
||||
if ( e.code != 'EEXIST' ) throw e;
|
||||
}
|
||||
}
|
||||
|
||||
function copyFiles(source: string, target: string) {
|
||||
var files = fs.readdirSync(source);
|
||||
files.forEach(function(file: any) {
|
||||
var sourceFile = path.join(source, file);
|
||||
var targetFile = path.join(target, file);
|
||||
var stat = fs.lstatSync(sourceFile);
|
||||
if (stat.isDirectory()) {
|
||||
mkdirSync(targetFile);
|
||||
copyFiles(sourceFile, targetFile);
|
||||
} else {
|
||||
fs.writeFileSync(targetFile, fs.readFileSync(sourceFile));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
deleteFolderRecursive(DEPLOY_TARGET);
|
||||
mkdirSync(DEPLOY_TARGET);
|
||||
copyFiles(DEPLOY_ENTRY, DEPLOY_TARGET);
|
||||
|
||||
console.log("Deployed to " + DEPLOY_TARGET);
|
Loading…
Add table
Add a link
Reference in a new issue