diff --git a/Jakefile.js b/Jakefile.js index b26f567f..9da1c0c7 100755 --- a/Jakefile.js +++ b/Jakefile.js @@ -72,6 +72,9 @@ task("mkjs", [], function () { amdlc.compileSource(modules, options); amdlc.compileDevelopment(modules, options); + var releaseInfo = tools.getReleaseInfo("./changelog.txt"); + tools.addReleaseDetailsTo(targetDir, releaseInfo); + // add compatibility if (process.env.compat !== 'no') { tools.addCompat({ diff --git a/build/BuildTools.js b/build/BuildTools.js index e3b81e10..afbe1188 100755 --- a/build/BuildTools.js +++ b/build/BuildTools.js @@ -288,7 +288,7 @@ var getReleaseInfo = function (srcPath) { if (!fs.existsSync(srcPath)) { console.info(srcPath + " cannot be found."); process.exit(1); - } + } var src = fs.readFileSync(srcPath).toString(); @@ -298,46 +298,53 @@ var getReleaseInfo = function (srcPath) { process.exit(1); } - // assume that very first file in array will have the copyright - var copyright = (function() { - var matches = fs.readFileSync(srcPath).toString().match(/^\/\*[\s\S]+?\*\//); - return matches ? matches[0] : null; - }()); - return { version: info[1], releaseDate: info[2], - fileVersion: info[1].replace(/\./g, '_'), - headNote: copyright - }; + fileVersion: info[1].replace(/\./g, '_') + } }; // inject version details and copyright header if available to all js files in specified directory -var addReleaseDetailsTo = function (dir, info) { - var contents, filePath; - - if (fs.existsSync(dir)) { - fs.readdirSync(dir).forEach(function(fileName) { - if (fileName && /\.js$/.test(fileName)) { - filePath = path.join(dir + "/" + fileName); - - if (info.headNote) { - contents = info.headNote + "\n" + fs.readFileSync(filePath).toString(); - } +var addReleaseDetailsTo = function (destPath, info) { + var self = this, headNote, headNotePath = "./build/headnote.txt"; - contents = contents.replace(/\@@([^@]+)@@/g, function($0, $1) { - switch ($1) { - case "version": return info.version; - case "releasedate": return info.releaseDate; - } - }); + function processFile(filePath) { + + if (headNote) { + contents = headNote + "\n" + fs.readFileSync(filePath); + } - fs.writeFileSync(filePath, contents); + contents = contents.replace(/@@([^@]+)@@/g, function($0, $1) { + switch ($1) { + case "version": return info.version; + case "releasedate": return info.releaseDate; } }); + + fs.writeFileSync(filePath, contents); + } + + function isTextFile(filePath) { + return /\.(js|txt)$/.filePath; + } + + if (fs.existsSync(headNotePath)) { + headNote = fs.readFileSync(headNotePath).toString(); + } + + var stat = fs.statSync(destPath); + + if (stat.isFile()) { + processFile(destPath); + } else if (stat.isDirectory()) { + fs.readdirSync(destPath).forEach(function(fileName) { + self.addReleaseDetailsTo(path.join(destPath, fileName), info); + }); } }; + function compileAmd(options) { require("amdlc").compile(options); } diff --git a/build/headnote.txt b/build/headnote.txt new file mode 100644 index 00000000..66ae7c7c --- /dev/null +++ b/build/headnote.txt @@ -0,0 +1,12 @@ +/** + * mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill + * v@@version@@ + * + * Copyright 2013, Moxiecode Systems AB + * Released under GPL License. + * + * License: http://www.plupload.com/license + * Contributing: http://www.plupload.com/contributing + * + * Date: @@releasedate@@ + */ \ No newline at end of file diff --git a/changelog.txt b/changelog.txt index a283e29f..73370926 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,15 +1,2 @@ -/** - * mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill - * v@@version@@ - * - * Copyright 2012, Moxiecode Systems AB - * Released under GPL License. - * - * License: http://www.plupload.com/license - * Contributing: http://www.plupload.com/contributing - * - * Date: @@releasedate@@ - */ - Version 1.0a (2012-11-13) First public alpha of mOxie. \ No newline at end of file