|
@ -85,9 +85,7 @@ async function appendContent(srcFile, targetFile, contentModifications = [], lin |
|
|
try { |
|
|
try { |
|
|
let content = await fs.readFile(srcFile, 'utf8'); |
|
|
let content = await fs.readFile(srcFile, 'utf8'); |
|
|
console.log(`Processing '${srcFile}'`); |
|
|
console.log(`Processing '${srcFile}'`); |
|
|
console.log(` READ: successfully!`); |
|
|
console.log(` READ: successfully!`, `Attepting to append file`); |
|
|
console.log(` Adding Copyright disclaimer!`); |
|
|
|
|
|
console.log(` Attepting to append to default script variant`); |
|
|
|
|
|
|
|
|
|
|
|
/* Apply modifications */ |
|
|
/* Apply modifications */ |
|
|
content = contentModifications |
|
|
content = contentModifications |
|
@ -122,8 +120,12 @@ async function bundleWithSpecifiedMode(targetFile, fileList, modulize = true) { |
|
|
|
|
|
|
|
|
let lineModifications = [ |
|
|
let lineModifications = [ |
|
|
function (line) { |
|
|
function (line) { |
|
|
|
|
|
|
|
|
let starters = ["function", "const", "let", "class"]; |
|
|
let starters = ["function", "const", "let", "class"]; |
|
|
return (starters.some(s => line.startsWith(s)) ? "export " : "") + line; |
|
|
if (starters.some(s => line.startsWith(s))) { |
|
|
|
|
|
return "export " + line; |
|
|
|
|
|
} |
|
|
|
|
|
return line; |
|
|
} |
|
|
} |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
@ -161,7 +163,7 @@ async function bundleWithSpecifiedMode(targetFile, fileList, modulize = true) { |
|
|
* @param {string|path} bundleFile path to the bundleFile if there is some |
|
|
* @param {string|path} bundleFile path to the bundleFile if there is some |
|
|
* - preparation for jpclw-bundler |
|
|
* - preparation for jpclw-bundler |
|
|
*/ |
|
|
*/ |
|
|
function bundle(targetFile = "./jpc-like-websites.js", modulize = true, bundleFile = './jpclw-bundle.json') { |
|
|
function bundle(modulize = false, targetFile = "./jpc-like-websites.js", bundleFile = './jpclw-bundle.json') { |
|
|
let fileOrder = require(bundleFile); |
|
|
let fileOrder = require(bundleFile); |
|
|
|
|
|
|
|
|
console.log("(Re-) Creating target file: '" + targetFile + "'"); |
|
|
console.log("(Re-) Creating target file: '" + targetFile + "'"); |
|
@ -169,7 +171,7 @@ function bundle(targetFile = "./jpc-like-websites.js", modulize = true, bundleFi |
|
|
fs.writeFile(targetFile, "", err => { }); |
|
|
fs.writeFile(targetFile, "", err => { }); |
|
|
|
|
|
|
|
|
if (modulize) { |
|
|
if (modulize) { |
|
|
let targetModule = path.basename(targetFile).split('.', 1)[0] + 'mjs'; |
|
|
let targetModule = path.basename(targetFile).split('.', 1)[0] + '.mjs'; |
|
|
fs.writeFile(targetModule, "", err => { }); |
|
|
fs.writeFile(targetModule, "", err => { }); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -187,5 +189,5 @@ function bundle(targetFile = "./jpc-like-websites.js", modulize = true, bundleFi |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
let args = process.argv.slice(2); |
|
|
let args = process.argv.slice(2); |
|
|
bundle(args[0], args[1], args[2]); |
|
|
bundle(Boolean(args[0]), args[1], args[2]); |
|
|
|
|
|
|
|
|