fix vars in Gruntfile

This commit is contained in:
Thomas Grainger 2017-04-13 19:00:55 +01:00
parent d05543db30
commit 5d271687ec
No known key found for this signature in database
GPG Key ID: 995EA0A029283160
1 changed files with 15 additions and 14 deletions

View File

@ -1,7 +1,7 @@
var webpack = require("webpack"), const webpack = require("webpack");
ExtractTextPlugin = require("extract-text-webpack-plugin"), const ExtractTextPlugin = require("extract-text-webpack-plugin");
HtmlWebpackPlugin = require("html-webpack-plugin"), const HtmlWebpackPlugin = require("html-webpack-plugin");
Inliner = require("web-resource-inliner"); const Inliner = require("web-resource-inliner");
module.exports = function (grunt) { module.exports = function (grunt) {
grunt.file.defaultEncoding = "utf8"; grunt.file.defaultEncoding = "utf8";
@ -54,7 +54,7 @@ module.exports = function (grunt) {
// Project configuration // Project configuration
var compileTime = grunt.template.today("dd/mm/yyyy HH:MM:ss") + " UTC", const compileTime = grunt.template.today("dd/mm/yyyy HH:MM:ss") + " UTC",
banner = "/**\n" + banner = "/**\n" +
"* CyberChef - The Cyber Swiss Army Knife\n" + "* CyberChef - The Cyber Swiss Army Knife\n" +
"*\n" + "*\n" +
@ -80,7 +80,7 @@ module.exports = function (grunt) {
* Compiles a production build of CyberChef into a single, portable web page. * Compiles a production build of CyberChef into a single, portable web page.
*/ */
function runInliner() { function runInliner() {
var inlinerError = false; const done = this.async();
Inliner.html({ Inliner.html({
relativeTo: "build/prod/", relativeTo: "build/prod/",
fileContent: grunt.file.read("build/prod/cyberchef.htm"), fileContent: grunt.file.read("build/prod/cyberchef.htm"),
@ -91,14 +91,16 @@ module.exports = function (grunt) {
strict: true strict: true
}, function(error, result) { }, function(error, result) {
if (error) { if (error) {
console.log(error); if (error instanceof Error) {
inlinerError = true; done(error)
return false; } else {
done(new Error(error));
}
} else {
grunt.file.write("build/prod/cyberchef.htm", result);
done(true);
} }
grunt.file.write("build/prod/cyberchef.htm", result);
}); });
return !inlinerError;
} }
grunt.initConfig({ grunt.initConfig({
@ -301,7 +303,7 @@ module.exports = function (grunt) {
copy: { copy: {
ghPages: { ghPages: {
options: { options: {
process: function (content, srcpath) { process: function (content) {
// Add Google Analytics code to index.html // Add Google Analytics code to index.html
content = content.replace("</body></html>", content = content.replace("</body></html>",
grunt.file.read("src/web/static/ga.html") + "</body></html>"); grunt.file.read("src/web/static/ga.html") + "</body></html>");
@ -342,5 +344,4 @@ module.exports = function (grunt) {
test: "build/test/index.js" test: "build/test/index.js"
}, },
}); });
}; };