Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var grunt = require('grunt');
var lf = grunt.util.linefeed;
var fs = require('fs');
var path = require('path');
var Helpers = {};
var base = process.cwd();
var glob = require('glob');
/* Overwrite browser env variables if grunt options are set */
var browsers = grunt.option('browser') || grunt.option('browsers');
if (browsers) {
process.env.KARMA_BROWSERS = browsers;
process.env.PROTRACTOR_BROWSERS = browsers;
}
var reporters = grunt.option('reporter') || grunt.option('reporters');
if (reporters) {
process.env.KARMA_REPORTERS = reporters;
process.env.PROTRACTOR_REPORTERS = reporters;
}
Helpers.config = {
pkg: grunt.file.readJSON('./package.json'),
env: process.env
};
Helpers.loadConfig = function(path) {
var glob = require('glob');
var object = {};
var key = null;
glob.sync('*', { cwd: path }).forEach(function(option) {
function runCli(name, gruntfile) {
var fn;
if (typeof gruntfile === 'function') {
fn = gruntfile;
} else {
fn = require(path.resolve(gruntfile));
}
if (typeof fn === 'function') {
fn.call(grunt, grunt);
if (grunt.task._tasks[name]) {
grunt.option('gruntfile', gruntfile);
grunt.option('base', process.cwd());
var task = grunt.task;
var fail = grunt.fail;
var uncaughtHandler = function(e) {
fail.fatal(e, fail.code.TASK_FAILURE);
};
process.on('uncaughtException', uncaughtHandler);
task.options({
error: function(e) {
fail.warn(e, fail.code.TASK_FAILURE);
},
done: function() {
process.removeListener('uncaughtException', uncaughtHandler);
fail.report();
/**
* Creates files
*
* https://www.npmjs.com/package/grunt-file-creator
*/
var grunt = require('grunt'),
component = grunt.option('name') || '',
date = new Date().toISOString().substring(0, 10);
module.exports = {
componentFiles: [
{
file: '<%= Config.PRIVATE_DIR %>/component/' + component + '/' + component + '.scss',
method: function (fs, fd, done) {
var content = "@charset \"utf-8\";\n" +
"/**\n" +
" * Capitan " + component + ".scss v1.0.0\n" +
" *\n" +
" * Copyright brandung GmbH & Co.KG\n" +
" * http://www.brandung.de/\n" +
" *\n" +
" * Date: " + date + "\n" +
" * MIT License (MIT)\n" +
parallelTask: function(args, options) {
var task = {
grunt: true,
args: args,
stream: options && options.stream
};
args.push('--port=' + this.sauceLabsAvailablePorts.pop());
if (args.indexOf('test:e2e') !== -1 && grunt.option('e2e-browsers')) {
args.push('--browsers=' + grunt.option('e2e-browsers'));
} else if (grunt.option('browsers')) {
args.push('--browsers=' + grunt.option('browsers'));
}
if (grunt.option('reporters')) {
args.push('--reporters=' + grunt.option('reporters'));
}
return task;
},
'use strict';
var grunt = require('grunt');
var reference = 'tools/perf/reference.json';
var samplesize = 50;
var engine = grunt.option('engine') || 'node';
var benchmark;
switch(engine) {
case 'jsshell':
benchmark = 'js benchmark.jsshell.js';
break;
case 'd8':
benchmark = 'd8 benchmark.d8.js';
break;
case 'node':
benchmark = 'node benchmark.node.js';
break;
default:
grunt.fatal('Unknown engine: ' + grunt.option('engine'));
}
var optPort = require('grunt').option('port');
var path = require('path');
var base = process.cwd();
module.exports = {
opendemo: {
command: 'sleep 1; open http://localhost:' + (optPort || process.env.DEMO_PORT || 8000) + '/'
},
deleteCoverages: {
command: [
'rm -rf',
path.join(base, '.tmp/coverage')
].join(' ')
}
};
function startServer(base, port) {
grunt.verbose.writeln('Starting static web server on port ' + port);
return server.start(base, port, { debug : grunt.option('debug') });
}
module.exports.register = function (Handlebars, options, params) {
"use strict";
var grunt = require("grunt")
var gruntfilePath = grunt.option("gruntfile") || ".";
var basePath = require("path").dirname(gruntfilePath);
var gruntFileConfig = basePath + "/gruntfileConfig.json";
var config = grunt.file.readJSON(gruntFileConfig);
Handlebars.registerHelper("cssFileName", function() {
return config.css.fileName + ".css";
})
};
startProtractor: function(config, done) {
var sauceUser = grunt.option('sauceUser');
var sauceKey = grunt.option('sauceKey');
var tunnelIdentifier = grunt.option('capabilities.tunnel-identifier');
var sauceBuild = grunt.option('capabilities.build');
var browser = grunt.option('browser');
var specs = grunt.option('specs');
var args = [config];
if (sauceUser) args.push('--sauceUser=' + sauceUser);
if (sauceKey) args.push('--sauceKey=' + sauceKey);
if (tunnelIdentifier) args.push('--capabilities.tunnel-identifier=' + tunnelIdentifier);
if (sauceBuild) args.push('--capabilities.build=' + sauceBuild);
if (specs) args.push('--specs=' + specs);
if (browser) {
args.push('--browser=' + browser);
}
function runCli(name, gruntfile) {
var fn;
if (typeof gruntfile === 'function') {
fn = gruntfile;
} else {
fn = require(path.resolve(gruntfile));
}
if (typeof fn === 'function') {
fn.call(grunt, grunt);
if (grunt.task._tasks[name]) {
grunt.option('gruntfile', gruntfile);
grunt.option('base', process.cwd());
var task = grunt.task;
var fail = grunt.fail;
var uncaughtHandler = function(e) {
fail.fatal(e, fail.code.TASK_FAILURE);
};
process.on('uncaughtException', uncaughtHandler);
task.options({
error: function(e) {
fail.warn(e, fail.code.TASK_FAILURE);
},
done: function() {
process.removeListener('uncaughtException', uncaughtHandler);