mirror of
https://github.com/JosunLP/BrowserExtensionTemplate.git
synced 2025-06-21 18:11:08 +00:00
cleaning
This commit is contained in:
parent
59fca4e2aa
commit
dbd1691445
2 changed files with 18 additions and 15 deletions
|
@ -5,6 +5,8 @@
|
||||||
[](https://github.com/JosunLP/BrowserExtensionTemplate/stargazers)
|
[](https://github.com/JosunLP/BrowserExtensionTemplate/stargazers)
|
||||||
[](https://github.com/JosunLP/BrowserExtensionTemplate)
|
[](https://github.com/JosunLP/BrowserExtensionTemplate)
|
||||||
[](https://twitter.com/intent/tweet?text=Look+what+i+found+on+GitHub+%23Developer%2C+%23SoftwareDeveloper%3A&url=https%3A%2F%2Fgithub.com%2FJosunLP%2FBrowserExtensionTemplate)
|
[](https://twitter.com/intent/tweet?text=Look+what+i+found+on+GitHub+%23Developer%2C+%23SoftwareDeveloper%3A&url=https%3A%2F%2Fgithub.com%2FJosunLP%2FBrowserExtensionTemplate)
|
||||||
|
[](https://www.codefactor.io/repository/github/josunlp/browserextensiontemplate)
|
||||||
|
[](https://snyk.io/test/github/JosunLP/BrowserExtensionTemplate)
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
|
import { ExecException } from 'child_process';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
const appConfig = JSON.parse(fs.readFileSync('./app.config.json', 'utf8'));
|
const appConfig = JSON.parse(fs.readFileSync('./app.config.json', 'utf8'));
|
||||||
var DEPLOY_ENTRY = "./public/";
|
const DEPLOY_ENTRY = "./public/";
|
||||||
var DEPLOY_TARGET = "./dist/";
|
const DEPLOY_TARGET = "./dist/";
|
||||||
|
|
||||||
function deleteFolderRecursive(path: string) {
|
function deleteFolderRecursive(path: string) {
|
||||||
if (fs.existsSync(path)) {
|
if (fs.existsSync(path)) {
|
||||||
fs.readdirSync(path).forEach(function (file: string) {
|
fs.readdirSync(path).forEach(function (file: string) {
|
||||||
var curPath = path + "/" + file;
|
const curPath = path + "/" + file;
|
||||||
if (fs.lstatSync(curPath).isDirectory()) {
|
if (fs.lstatSync(curPath).isDirectory()) {
|
||||||
deleteFolderRecursive(curPath);
|
deleteFolderRecursive(curPath);
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,11 +20,11 @@ function deleteFolderRecursive(path: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function findHtmlFilesRecursive(source: string): string[] {
|
function findHtmlFilesRecursive(source: string): string[] {
|
||||||
var files: string[] = [];
|
let files: string[] = [];
|
||||||
var dir = fs.readdirSync(source);
|
const dir = fs.readdirSync(source);
|
||||||
dir.forEach(function (file: any) {
|
dir.forEach(function (file: string) {
|
||||||
var sourceFile = path.join(source, file);
|
const sourceFile = path.join(source, file);
|
||||||
var stat = fs.lstatSync(sourceFile);
|
const stat = fs.lstatSync(sourceFile);
|
||||||
if (stat.isDirectory()) {
|
if (stat.isDirectory()) {
|
||||||
files = files.concat(findHtmlFilesRecursive(sourceFile));
|
files = files.concat(findHtmlFilesRecursive(sourceFile));
|
||||||
} else {
|
} else {
|
||||||
|
@ -36,9 +37,9 @@ function findHtmlFilesRecursive(source: string): string[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceKeywordsInHtmlFile(file: string) {
|
function replaceKeywordsInHtmlFile(file: string) {
|
||||||
var content = fs.readFileSync(file, 'utf8');
|
const content = fs.readFileSync(file, 'utf8');
|
||||||
let pairs = appConfig.htmlTemplatePairs;
|
let pairs = appConfig.htmlTemplatePairs;
|
||||||
pairs.forEach(function (pair: any) {
|
pairs.forEach(function (pair: object) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
content = content.replaceAll(pair.key, pair.value);
|
content = content.replaceAll(pair.key, pair.value);
|
||||||
});
|
});
|
||||||
|
@ -62,11 +63,11 @@ function mkdirSync(path: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyFiles(source: string, target: string) {
|
function copyFiles(source: string, target: string) {
|
||||||
var files = fs.readdirSync(source);
|
const files = fs.readdirSync(source);
|
||||||
files.forEach(function (file: any) {
|
files.forEach(function (file: string) {
|
||||||
var sourceFile = path.join(source, file);
|
const sourceFile = path.join(source, file);
|
||||||
var targetFile = path.join(target, file);
|
const targetFile = path.join(target, file);
|
||||||
var stat = fs.lstatSync(sourceFile);
|
const stat = fs.lstatSync(sourceFile);
|
||||||
if (stat.isDirectory()) {
|
if (stat.isDirectory()) {
|
||||||
mkdirSync(targetFile);
|
mkdirSync(targetFile);
|
||||||
copyFiles(sourceFile, targetFile);
|
copyFiles(sourceFile, targetFile);
|
||||||
|
|
Loading…
Add table
Reference in a new issue