options.process undefined, even though it's not
trydalch opened this issue · 1 comments
trydalch commented
I'm currently trying to migrate from grunt-typescript to grunt-ts. I have all the other tasks working as expected right now, but when trying to use a process function in the concat task, it's undefined and fails. When I comment out the options
block, it executes successfully.
What's wrong here?
grunt-ts version: 5.5.1
grunt-contrib-concat version: 0.4.0
Error message:
Running "concat:fql" (concat) task
Verifying property concat.fql exists in config...OK
Files: fql/albumPhotosByOwners.fql, fql/commentsForObject.fql, fql/commentsForObjectIds.fql, fql/friendListByName.fql, fql/linksByOwners.fql, fql/photosByOwners.fql, fql/postsByOwners.fql, fql/profilesForAlbumAndTaggedPhotos.fql, fql/statusesByOwners.fql, fql/streamsByOwners.fql, fql/taggedPhotosBySubjects.fql, fql/tagsForAlbumAndTaggedPhotos.fql, fql/userNames.fql, fql/videosByOwners.fql -> dist/
fql.js
Options: separator="\r\n", banner="APP.fql = {};\r\n", footer="", stripBanners=false, process=undefined
Reading fql/albumPhotosByOwners.fql...OK
Gruntfile.js
//
module.exports = function (grunt) {
grunt.initConfig({
temp_dir: "www-temp",
out_dir: "dist",
test_dir: "tests",
ts: {
options: {
sourceMap: false,
},
dev: {
tsconfig: 'tsconfig.json',
sourceMap: true,
tsconfigRootDir: __dirname,
out: "<%= out_dir %>/app.js"
}
},
clean: {
out: {
src: ["<%= out_dir %>"]
},
temp: {
src: ["<%= temp_dir %>"]
},
test: {
src: ["<%= test_dir %>"]
}
},
concat: {
libs: {
src: [
// ie console
"lib/console.js",
// libs
"lib/knockout-2.2.1.js", "lib/browser-detection.js", "lib/underscore.js", "lib/backbone.js", "lib/mustache.js", "lib/json2.js",
// jquery plugins
"lib/jquery.tooltip.js", "lib/jquery.kin2input.js", "lib/jquery.mousewheel.js",
// paperjs
"lib/paperscript.js",
"lib/ext-all-dev.js",
],
dest: "dist/libs.js",
options: {},
},
data: {
src: "data/**/*.js",
dest: "dist/data.js",
options: {
banner: "(function(){",
footer: "})();",
},
},
fql: {
src: "fql/**/*.fql",
dest: "<%= out_dir %>/fql.js",
options: {
banner: "APP.fql = {};\n",
process: function (src, filepath) {
// remove comments --text to end of line
src = src.replace(/--.*$/gm, ''); // 'm' is needed for $ to work
// replace whitespace with a single space
src = src.replace(/\s+/g, ' ');
// replace symbols surrounded by whitespace with only the symbol
src = src.replace(/\s*([,;:()\[\]])\s*/g, "$1");
// create a function so options(o) can be passed in
return "APP.fql[\"" + path.basename(filepath, ".fql") + "\"]=function(o){return \"" + src.trim() + "\";}";
},
},
},
templates: {
src: "templates/**/*.html",
dest: "dist/templates.js",
options: {
banner: "APP.templates = {};\n",
process: function (src, filepath) {
// remove utf8 BOM if it exists
if (src.indexOf('\uFEFF') === 0) {
src = src.substring(1, src.length);
}
// escape double quotes
src = src.replace(/\"/g, '\\"');
// remove comments <!--(match anything except for "-->")-->
src = src.replace(/<!--((?!-->)[\S\s])*-->/g, "");
// remove newlines
src = src.replace(/\r/g, " ");
src = src.replace(/\n/g, " ");
// ## escape newlines
//src = src.replace(/\r/g, '\\r')
//src = src.replace(/\n/g, '\\n')
// normalize spaces
src = src.replace(/\s{2,}/g, " ");
//
return "APP.templates['" + path.basename(filepath) + "'] = \"" + src + "\";";
},
},
}
}
},
uglify: {},
testtmpls: {
test: {
options: {
indexTemplate: "specs/helpers/tmpl-index.html",
testTemplate: "specs/helpers/tmpl-test.html",
},
src: "specs/*-spec.js",
dest: "<%= test_dir %>/",
}
},
});
// Load plugins
grunt.loadNpmTasks("grunt-contrib-concat");
// Load grunt-ts
grunt.loadNpmTasks("grunt-ts");
// Register default (dev) task.
grunt.registerTask("default", [
"clean",
"concat",
"ts:dev"
]);
};
trydalch commented
I missed the var path = require("path");
line at the top of the old gruntfile 🤦