Script Jake de compilation
This commit is contained in:
parent
6859df7acc
commit
c3695ad5fa
46
Jakefile.js
Normal file
46
Jakefile.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/* global jake,process */
|
||||||
|
/**
|
||||||
|
* Installer Jake avec npm install -g jake (NodeJs doit être installé préalablement)
|
||||||
|
*
|
||||||
|
* Lancer la compilation avec jake build[$version] où $version est le numéro de version
|
||||||
|
*/
|
||||||
|
|
||||||
|
var fs = require('fs')
|
||||||
|
, exec = require('child_process').exec;
|
||||||
|
|
||||||
|
task('build', function (version) {
|
||||||
|
jake.rmRf('dist');
|
||||||
|
jake.mkdirP('dist');
|
||||||
|
compileJs(version, 'html2ods.js');
|
||||||
|
});
|
||||||
|
|
||||||
|
task('default', ['build']);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile les différents fichiers Javascript suivant l'ordre indiqué dans list.txt
|
||||||
|
* en un fichier Javascript unique
|
||||||
|
* Les fichiers Javascript sont vidés de leurs commentaires et des espaces blancs surnuméraires.
|
||||||
|
*
|
||||||
|
* @param {string} version version de la compilation
|
||||||
|
* @param {string} destination nom du fichier de destination
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
|
function compileJs(version, destination) {
|
||||||
|
var files = fs.readFileSync('list.txt', 'utf8').split("\n");
|
||||||
|
var result = "";
|
||||||
|
for (let i = 0, len = files.length; i < len; i++) {
|
||||||
|
var fileName = files[i];
|
||||||
|
if (fileName.length > 0) {
|
||||||
|
var contents = fs.readFileSync("src/js/" + fileName, 'utf8');
|
||||||
|
contents = contents.replace(/\/\*[\s\S]*?\*\//g,'');
|
||||||
|
result = result + contents;
|
||||||
|
console.log(files[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = result.replace(/\n\s*\n/g, "\n");
|
||||||
|
var moduleContent = fs.readFileSync("src/js/Html2Ods.js", 'utf8');
|
||||||
|
moduleContent = "/* version: " + version + " */\n" + moduleContent.replace(/\/\*[\s\S]*?\*\//g,'');
|
||||||
|
moduleContent = moduleContent.replace("//compile target", result);
|
||||||
|
|
||||||
|
fs.writeFileSync('dist/' + destination, moduleContent, 'utf8');
|
||||||
|
}
|
9
list.txt
Normal file
9
list.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
currency/Currency.js
|
||||||
|
xmlwriter/XmlWriter.js
|
||||||
|
opendocument/OpenDocument.js
|
||||||
|
opendocument/OpenDocument.Elements.js
|
||||||
|
opendocument/OpenDocument.CellCounter.js
|
||||||
|
opendocument/OpenDocument.XmlWriter.js
|
||||||
|
opendocument/OpenDocument.Style.js
|
||||||
|
opendocument/OpenDocument.StyleManager.js
|
||||||
|
opendocument/OpenDocument.OdsConverter.js
|
Loading…
Reference in New Issue
Block a user