Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
render_file: function(layout_data, file_data, helpers) {
grunt.log.debug('render_file(): executed');
// set the base dir for includes
// tj uses filename to set base dir for includes in ejs.js
// which make the include relative to the file
// see resolveInclude() in visionmedia/ejs/lib/ejs.js
file_data.filename = layout_data.path_to_layout;
// add any helpers to the file_data object
if (_.keys(helpers).length > 0) {
_.extend(file_data, helpers);
grunt.log.debug('render.js render_file() the value of helpers is :' + Object.keys(helpers));
}
grunt.log.debug('data available for this template ' + Object.keys(file_data));
// render the template as html and return the result
var rendered_file = ejs.render(layout_data.layout, file_data);
return rendered_file;
}
// end render the file
path_to_file = underscores_to_dashes(path_to_file);
grunt.log.debug('path to html file is ' + path_to_file);
// write file to the destination directory
grunt.file.write(path_to_file, rendered_file);
grunt.log.debug('Rendered root level file written to ' + path_to_file);
} else {
// create the file with the key as the file name
path_to_file = path.join(options.dest, key + options.file_extension);
path_to_file = underscores_to_dashes(path_to_file);
grunt.log.debug('path to html file is ' + path_to_file);
// write file to the destination directory
grunt.file.write(path_to_file, rendered_file);
grunt.log.debug('Rendered root level file written to ' + path_to_file);
}
}
// end create a file at root level
beforeEach(function (done) {
sandbox = sinon.sandbox.create();
fs.stat(reporterOutFile, function (err, stats) {
if (!err) {
fs.unlink(reporterOutFile, done);
} else {
done();
}
});
errorlnsStub = sandbox.stub(grunt.log, 'errorlns');
oklnsStub = sandbox.stub(grunt.log, 'oklns');
writelnStub = sandbox.stub(grunt.log, 'writeln');
});
grunt.registerTask('validateandruntaskv2', 'if task available then run given task with multiple args', function(taskname) {
if(!taskname || !taskname.length) {
grunt.fail.fatal('task name is needed to run this task');
}
var taskToCall = taskname;
for(var i = 1; i < arguments.length; i++) {
taskToCall += ':' + arguments[i];
}
console.log(taskToCall);
if(!grunt.task.exists(taskname)) {
grunt.log.writeln('this task does not exist!');
} else {
grunt.log.writeln(taskname + ' exists. Going to run this task');
grunt.task.run(taskToCall);
}
});
run: function () {
var self = this;
var s3 = this.s3;
var done = this._origTask.async();
var config = this.getConfig();
var transfers = [];
if (config.debug) {
grunt.log.writeln('Running in debug mode, no transfers will be made'.yellow);
grunt.log.writeln();
}
config.upload.forEach(function (upload) {
var uploadFiles = self._parseUploadFiles(upload, config);
uploadFiles.forEach(function (uploadFile) {
transfers.push(s3.upload.bind(s3, uploadFile.file, uploadFile.dest, uploadFile.upload));
});
});
config.sync.forEach(function (sync) {
var syncFiles = self._parseUploadFiles(sync, config);
syncFiles.forEach(function (syncFile) {
transfers.push(s3.sync.bind(s3, syncFile.file, syncFile.dest, syncFile.upload));
exports.options = function() {
grunt.log.header('Options');
exports.table(exports._options);
};
function blown () {
var args = _.toArray(arguments);
if (options.fatal !== false) {
grunt.fatal.apply(grunt, args);
} else {
grunt.log.writeln.call(grunt.log, args);
done();
}
}
}
var safelyEvalFile = function (fileUrl) {
if (!grunt.file.exists(fileUrl)) {
grunt.log.error("Source file '" + fileUrl + "' not found.");
}
try {
eval(grunt.file.read(fileUrl));
} catch (e) {
grunt.log.error("An unexpected error occured while processing " + fileUrl + ", please report a bug here if problems occur in your app " +
"https://github.com/mattgoldspink/grunt-sencha-dependencies/issues?state=open - " + e);
if (e.stack) {
grunt.log.error("Stack for debugging: \n" + e.stack);
}
throw e;
}
return Ext;
};
function getTsc(binPath: string): string {
var pkg = JSON.parse(fs.readFileSync(path.resolve(binPath, '..', 'package.json')).toString());
grunt.log.writeln('Using tsc v' + pkg.version);
return path.join(binPath, 'tsc');
}