Added Gulp.js for compiling SCSS stylesheets
This commit is contained in:
41
node_modules/gulp-cli/lib/shared/ansi.js
generated
vendored
Normal file
41
node_modules/gulp-cli/lib/shared/ansi.js
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
var colors = require('ansi-colors');
|
||||
var supportsColor = require('color-support');
|
||||
|
||||
var hasColors = colorize();
|
||||
|
||||
/* istanbul ignore next */
|
||||
module.exports = {
|
||||
red: hasColors ? colors.red : noColor,
|
||||
green: hasColors ? colors.green : noColor,
|
||||
blue: hasColors ? colors.blue : noColor,
|
||||
magenta: hasColors ? colors.magenta : noColor,
|
||||
cyan: hasColors ? colors.cyan : noColor,
|
||||
white: hasColors ? colors.white : noColor,
|
||||
gray: hasColors ? colors.gray : noColor,
|
||||
bgred: hasColors ? colors.bgred : noColor,
|
||||
bold: hasColors ? colors.bold : noColor,
|
||||
yellow: hasColors ? colors.yellow : noColor,
|
||||
};
|
||||
|
||||
function noColor(message) {
|
||||
return message;
|
||||
}
|
||||
|
||||
function hasFlag(flag) {
|
||||
return (process.argv.indexOf('--' + flag) !== -1);
|
||||
}
|
||||
|
||||
function colorize() {
|
||||
if (hasFlag('no-color')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* istanbul ignore if */
|
||||
if (hasFlag('color')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return supportsColor();
|
||||
}
|
122
node_modules/gulp-cli/lib/shared/cli-options.js
generated
vendored
Normal file
122
node_modules/gulp-cli/lib/shared/cli-options.js
generated
vendored
Normal file
@ -0,0 +1,122 @@
|
||||
'use strict';
|
||||
|
||||
var ansi = require('./ansi');
|
||||
|
||||
module.exports = {
|
||||
help: {
|
||||
alias: 'h',
|
||||
type: 'boolean',
|
||||
desc: ansi.gray(
|
||||
'Show this help.'),
|
||||
},
|
||||
version: {
|
||||
alias: 'v',
|
||||
type: 'boolean',
|
||||
desc: ansi.gray(
|
||||
'Print the global and local gulp versions.'),
|
||||
},
|
||||
require: {
|
||||
type: 'string',
|
||||
requiresArg: true,
|
||||
desc: ansi.gray(
|
||||
'Will require a module before running the gulpfile. ' +
|
||||
'This is useful for transpilers but also has other applications.'),
|
||||
},
|
||||
gulpfile: {
|
||||
alias: 'f',
|
||||
type: 'string',
|
||||
requiresArg: true,
|
||||
desc: ansi.gray(
|
||||
'Manually set path of gulpfile. Useful if you have multiple gulpfiles. ' +
|
||||
'This will set the CWD to the gulpfile directory as well.'),
|
||||
},
|
||||
cwd: {
|
||||
type: 'string',
|
||||
requiresArg: true,
|
||||
desc: ansi.gray(
|
||||
'Manually set the CWD. The search for the gulpfile, ' +
|
||||
'as well as the relativity of all requires will be from here.'),
|
||||
},
|
||||
verify: {
|
||||
desc: ansi.gray(
|
||||
'Will verify plugins referenced in project\'s package.json against ' +
|
||||
'the plugins blacklist.'),
|
||||
},
|
||||
tasks: {
|
||||
alias: 'T',
|
||||
type: 'boolean',
|
||||
desc: ansi.gray(
|
||||
'Print the task dependency tree for the loaded gulpfile.'),
|
||||
},
|
||||
'tasks-simple': {
|
||||
type: 'boolean',
|
||||
desc: ansi.gray(
|
||||
'Print a plaintext list of tasks for the loaded gulpfile.'),
|
||||
},
|
||||
'tasks-json': {
|
||||
desc: ansi.gray(
|
||||
'Print the task dependency tree, ' +
|
||||
'in JSON format, for the loaded gulpfile.'),
|
||||
},
|
||||
'tasks-depth': {
|
||||
alias: 'depth',
|
||||
type: 'number',
|
||||
requiresArg: true,
|
||||
default: undefined, // To detect if this cli option is specified.
|
||||
desc: ansi.gray(
|
||||
'Specify the depth of the task dependency tree.'),
|
||||
},
|
||||
'compact-tasks': {
|
||||
type: 'boolean',
|
||||
default: undefined, // To detect if this cli option is specified.
|
||||
desc: ansi.gray(
|
||||
'Reduce the output of task dependency tree by printing ' +
|
||||
'only top tasks and their child tasks.'),
|
||||
},
|
||||
'sort-tasks': {
|
||||
type: 'boolean',
|
||||
default: undefined, // To detect if this cli option is specified.
|
||||
desc: ansi.gray(
|
||||
'Will sort top tasks of task dependency tree.'),
|
||||
},
|
||||
color: {
|
||||
type: 'boolean',
|
||||
desc: ansi.gray(
|
||||
'Will force gulp and gulp plugins to display colors, ' +
|
||||
'even when no color support is detected.'),
|
||||
},
|
||||
'no-color': {
|
||||
type: 'boolean',
|
||||
desc: ansi.gray(
|
||||
'Will force gulp and gulp plugins to not display colors, ' +
|
||||
'even when color support is detected.'),
|
||||
},
|
||||
silent: {
|
||||
alias: 'S',
|
||||
type: 'boolean',
|
||||
default: undefined, // To detect if this cli option is specified.
|
||||
desc: ansi.gray(
|
||||
'Suppress all gulp logging.'),
|
||||
},
|
||||
continue: {
|
||||
type: 'boolean',
|
||||
default: undefined, // To detect if this cli option is specified.
|
||||
desc: ansi.gray(
|
||||
'Continue execution of tasks upon failure.'),
|
||||
},
|
||||
series: {
|
||||
type: 'boolean',
|
||||
default: undefined, // To detect if this cli option is specified.
|
||||
desc: ansi.gray(
|
||||
'Run tasks given on the CLI in series (the default is parallel).'),
|
||||
},
|
||||
'log-level': {
|
||||
alias: 'L',
|
||||
// Type isn't needed because count acts as a boolean
|
||||
count: true,
|
||||
default: undefined, // To detect if this cli option is specified.
|
||||
desc: ansi.gray(
|
||||
'Set the loglevel. -L for least verbose and -LLLL for most verbose. ' +
|
||||
'-LLL is default.'),
|
||||
},
|
||||
};
|
22
node_modules/gulp-cli/lib/shared/completion.js
generated
vendored
Normal file
22
node_modules/gulp-cli/lib/shared/completion.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
module.exports = function(name) {
|
||||
if (typeof name !== 'string') {
|
||||
throw new Error('Missing completion type');
|
||||
}
|
||||
var file = path.join(__dirname, '../../completion', name);
|
||||
try {
|
||||
console.log(fs.readFileSync(file, 'utf8'));
|
||||
process.exit(0);
|
||||
} catch (err) {
|
||||
console.log(
|
||||
'echo "gulp autocompletion rules for',
|
||||
'\'' + name + '\'',
|
||||
'not found"'
|
||||
);
|
||||
process.exit(5);
|
||||
}
|
||||
};
|
25
node_modules/gulp-cli/lib/shared/config/cli-flags.js
generated
vendored
Normal file
25
node_modules/gulp-cli/lib/shared/config/cli-flags.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
var copyProps = require('copy-props');
|
||||
|
||||
var fromTo = {
|
||||
'flags.silent': 'silent',
|
||||
'flags.continue': 'continue',
|
||||
'flags.series': 'series',
|
||||
'flags.logLevel': 'logLevel',
|
||||
'flags.compactTasks': 'compactTasks',
|
||||
'flags.tasksDepth': 'tasksDepth',
|
||||
'flags.sortTasks': 'sortTasks',
|
||||
};
|
||||
|
||||
function mergeConfigToCliFlags(opt, config) {
|
||||
return copyProps(config, opt, fromTo, defaults);
|
||||
}
|
||||
|
||||
function defaults(cfgInfo, optInfo) {
|
||||
if (optInfo.value === undefined) {
|
||||
return cfgInfo.value;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = mergeConfigToCliFlags;
|
44
node_modules/gulp-cli/lib/shared/config/env-flags.js
generated
vendored
Normal file
44
node_modules/gulp-cli/lib/shared/config/env-flags.js
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var copyProps = require('copy-props');
|
||||
|
||||
var toFrom = {
|
||||
configPath: 'flags.gulpfile',
|
||||
configBase: 'flags.gulpfile',
|
||||
require: 'flags.require',
|
||||
nodeFlags: 'flags.nodeFlags',
|
||||
};
|
||||
|
||||
function mergeConfigToEnvFlags(env, config, cliOpts) {
|
||||
// This must reverse because `flags.gulpfile` determines 2 different properties
|
||||
var reverse = true;
|
||||
return copyProps(env, config, toFrom, convert, reverse);
|
||||
|
||||
function convert(configInfo, envInfo) {
|
||||
if (envInfo.keyChain === 'configBase') {
|
||||
if (cliOpts.gulpfile === undefined) {
|
||||
return path.dirname(configInfo.value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (envInfo.keyChain === 'configPath') {
|
||||
if (cliOpts.gulpfile === undefined) {
|
||||
return configInfo.value;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (envInfo.keyChain === 'require') {
|
||||
return [].concat(envInfo.value, configInfo.value);
|
||||
}
|
||||
|
||||
/* istanbul ignore else */
|
||||
if (envInfo.keyChain === 'nodeFlags') {
|
||||
return [].concat(configInfo.value || []);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = mergeConfigToEnvFlags;
|
30
node_modules/gulp-cli/lib/shared/config/load-files.js
generated
vendored
Normal file
30
node_modules/gulp-cli/lib/shared/config/load-files.js
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
var copyProps = require('copy-props');
|
||||
var path = require('path');
|
||||
|
||||
function loadConfigFiles(configFiles, configFileOrder) {
|
||||
var config = {};
|
||||
|
||||
configFileOrder.forEach(loadFile);
|
||||
|
||||
function loadFile(key) {
|
||||
var filePath = configFiles[key];
|
||||
if (!filePath) {
|
||||
return;
|
||||
}
|
||||
|
||||
copyProps(require(filePath), config, convert);
|
||||
|
||||
function convert(loadedInfo) {
|
||||
if (loadedInfo.keyChain === 'flags.gulpfile') {
|
||||
return path.resolve(path.dirname(filePath), loadedInfo.value);
|
||||
}
|
||||
return loadedInfo.value;
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
module.exports = loadConfigFiles;
|
15
node_modules/gulp-cli/lib/shared/exit.js
generated
vendored
Normal file
15
node_modules/gulp-cli/lib/shared/exit.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
// Fix stdout truncation on windows
|
||||
function exit(code) {
|
||||
/* istanbul ignore next */
|
||||
if (process.platform === 'win32' && process.stdout.bufferSize) {
|
||||
process.stdout.once('drain', function() {
|
||||
process.exit(code);
|
||||
});
|
||||
return;
|
||||
}
|
||||
process.exit(code);
|
||||
}
|
||||
|
||||
module.exports = exit;
|
62
node_modules/gulp-cli/lib/shared/get-blacklist.js
generated
vendored
Normal file
62
node_modules/gulp-cli/lib/shared/get-blacklist.js
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
'use strict';
|
||||
|
||||
var https = require('https');
|
||||
|
||||
var concat = require('concat-stream');
|
||||
|
||||
var url = 'https://raw.githubusercontent.com/gulpjs/plugins/master/src/blackList.json';
|
||||
|
||||
function collect(stream, cb) {
|
||||
stream.on('error', cb);
|
||||
stream.pipe(concat(onSuccess));
|
||||
|
||||
function onSuccess(result) {
|
||||
cb(null, result);
|
||||
}
|
||||
}
|
||||
|
||||
function parse(str, cb) {
|
||||
try {
|
||||
cb(null, JSON.parse(str));
|
||||
} catch (err) {
|
||||
/* istanbul ignore next */
|
||||
cb(new Error('Invalid Blacklist JSON.'));
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Test this impl
|
||||
function getBlacklist(cb) {
|
||||
https.get(url, onRequest);
|
||||
|
||||
function onRequest(res) {
|
||||
/* istanbul ignore if */
|
||||
if (res.statusCode !== 200) {
|
||||
// TODO: Test different status codes
|
||||
return cb(new Error('Request failed. Status Code: ' + res.statusCode));
|
||||
}
|
||||
|
||||
res.setEncoding('utf8');
|
||||
|
||||
collect(res, onCollect);
|
||||
}
|
||||
|
||||
function onCollect(err, result) {
|
||||
/* istanbul ignore if */
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
parse(result, onParse);
|
||||
}
|
||||
|
||||
function onParse(err, blacklist) {
|
||||
/* istanbul ignore if */
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
cb(null, blacklist);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = getBlacklist;
|
15
node_modules/gulp-cli/lib/shared/log/blacklist-error.js
generated
vendored
Normal file
15
node_modules/gulp-cli/lib/shared/log/blacklist-error.js
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
var log = require('gulplog');
|
||||
|
||||
var ansi = require('../ansi');
|
||||
var exit = require('../exit');
|
||||
|
||||
/* istanbul ignore next */
|
||||
function logBlacklistError(err) {
|
||||
log.error(ansi.red('Error: failed to retrieve plugins black-list'));
|
||||
log.error(err.message); // Avoid duplicating for each version
|
||||
exit(1);
|
||||
}
|
||||
|
||||
module.exports = logBlacklistError;
|
81
node_modules/gulp-cli/lib/shared/log/copy-tree.js
generated
vendored
Normal file
81
node_modules/gulp-cli/lib/shared/log/copy-tree.js
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
'use strict';
|
||||
|
||||
function copyNode(node) {
|
||||
var newNode = {};
|
||||
Object.keys(node).forEach(function(key) {
|
||||
newNode[key] = node[key];
|
||||
});
|
||||
return newNode;
|
||||
}
|
||||
|
||||
var defaultNodeFactory = {
|
||||
topNode: copyNode,
|
||||
taskNode: copyNode,
|
||||
childNode: copyNode,
|
||||
};
|
||||
|
||||
function copyTree(tree, opts, nodeFactory) {
|
||||
opts = opts || {};
|
||||
|
||||
var depth = opts.tasksDepth;
|
||||
depth = typeof depth === 'number' ? ((depth < 1) ? 1 : depth) : null;
|
||||
|
||||
nodeFactory = nodeFactory || defaultNodeFactory;
|
||||
|
||||
var newTree = nodeFactory.topNode(tree);
|
||||
newTree.nodes = [];
|
||||
|
||||
if (Array.isArray(tree.nodes)) {
|
||||
tree.nodes.forEach(visit);
|
||||
}
|
||||
|
||||
function visit(node) {
|
||||
var newNode = nodeFactory.taskNode(node);
|
||||
newNode.nodes = [];
|
||||
newTree.nodes.push(newNode);
|
||||
|
||||
if (opts.compactTasks) {
|
||||
forEach(node.nodes, copyNotRecursively, newNode);
|
||||
|
||||
} else if (!depth || depth > 1) {
|
||||
forEach(node.nodes, copyRecursively, depth, 2, newNode);
|
||||
}
|
||||
}
|
||||
|
||||
function copyNotRecursively(child, newParent) {
|
||||
var newChild = nodeFactory.childNode(child);
|
||||
newChild.nodes = [];
|
||||
newParent.nodes.push(newChild);
|
||||
|
||||
if (child.branch) {
|
||||
forEach(child.nodes, copyNotRecursively, newChild);
|
||||
}
|
||||
}
|
||||
|
||||
function copyRecursively(child, maxDepth, nowDepth, newParent) {
|
||||
var newChild = nodeFactory.childNode(child);
|
||||
newChild.nodes = [];
|
||||
newParent.nodes.push(newChild);
|
||||
|
||||
if (!maxDepth || maxDepth > nowDepth) {
|
||||
forEach(child.nodes, copyRecursively, maxDepth, nowDepth + 1, newChild);
|
||||
}
|
||||
}
|
||||
|
||||
return newTree;
|
||||
}
|
||||
|
||||
function forEach(nodes, fn) {
|
||||
if (!Array.isArray(nodes)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var args = Array.prototype.slice.call(arguments, 2);
|
||||
|
||||
for (var i = 0, n = nodes.length; i < n; i++) {
|
||||
fn.apply(nodes[i], [nodes[i]].concat(args));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = copyTree;
|
||||
|
166
node_modules/gulp-cli/lib/shared/log/tasks.js
generated
vendored
Normal file
166
node_modules/gulp-cli/lib/shared/log/tasks.js
generated
vendored
Normal file
@ -0,0 +1,166 @@
|
||||
'use strict';
|
||||
|
||||
var archy = require('archy');
|
||||
var log = require('gulplog');
|
||||
|
||||
var sortBy = require('array-sort');
|
||||
var isObject = require('isobject');
|
||||
|
||||
var ansi = require('../ansi');
|
||||
var copyTree = require('./copy-tree');
|
||||
|
||||
function logTasks(tree, opts, getTask) {
|
||||
if (opts.sortTasks) {
|
||||
tree.nodes = sortBy(tree.nodes, 'label');
|
||||
}
|
||||
|
||||
var lineInfos = [];
|
||||
var entryObserver = getLineInfoCollector(lineInfos);
|
||||
var nodeFactory = getNodeFactory(getTask, entryObserver);
|
||||
|
||||
tree = copyTree(tree, opts, nodeFactory);
|
||||
var spacer = getSpacerForLineIndents(tree, lineInfos);
|
||||
var lines = getLinesContainingOnlyBranches(tree);
|
||||
|
||||
log.info(tree.label);
|
||||
printTreeList(lines, spacer, lineInfos);
|
||||
}
|
||||
|
||||
function getLineInfoCollector(lineInfos) {
|
||||
return {
|
||||
topTask: function(node) {
|
||||
lineInfos.push({
|
||||
name: node.label,
|
||||
desc: node.desc,
|
||||
type: 'top',
|
||||
});
|
||||
},
|
||||
option: function(opt) {
|
||||
lineInfos.push({
|
||||
name: opt.label,
|
||||
desc: opt.desc,
|
||||
type: 'option',
|
||||
});
|
||||
},
|
||||
childTask: function(node) {
|
||||
lineInfos.push({
|
||||
name: node.label,
|
||||
type: 'child',
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function getNodeFactory(getTask, entryObserver) {
|
||||
return {
|
||||
topNode: function(node) {
|
||||
return {
|
||||
label: node.label,
|
||||
};
|
||||
},
|
||||
|
||||
taskNode: function(node) {
|
||||
/* istanbul ignore next */
|
||||
var task = getTask(node.label) || {};
|
||||
|
||||
var newNode = {
|
||||
label: node.label,
|
||||
desc: typeof task.description === 'string' ? task.description : '',
|
||||
opts: [],
|
||||
};
|
||||
entryObserver.topTask(newNode);
|
||||
|
||||
if (isObject(task.flags)) {
|
||||
Object.keys(task.flags).sort().forEach(function(flag) {
|
||||
if (flag.length === 0) {
|
||||
return;
|
||||
}
|
||||
/* istanbul ignore next */
|
||||
var opt = {
|
||||
label: flag,
|
||||
desc: typeof task.flags[flag] === 'string' ? task.flags[flag] : '',
|
||||
};
|
||||
entryObserver.option(opt);
|
||||
newNode.opts.push(opt);
|
||||
newNode.label += '\n' + opt.label; // The way of archy for options.
|
||||
});
|
||||
}
|
||||
|
||||
return newNode;
|
||||
},
|
||||
|
||||
childNode: function(node) {
|
||||
var newChild = {
|
||||
label: node.label,
|
||||
};
|
||||
entryObserver.childTask(newChild);
|
||||
newChild.label = ''; // Because don't use child tasks to calc indents.
|
||||
|
||||
return newChild;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function getSpacerForLineIndents(tree, lineInfos) {
|
||||
var maxSize = 0;
|
||||
var sizes = [];
|
||||
|
||||
archy(tree)
|
||||
.split('\n')
|
||||
.slice(1, -1)
|
||||
.forEach(function(line, index) {
|
||||
var info = lineInfos[index];
|
||||
if (info.type === 'top' || info.type === 'option') {
|
||||
maxSize = Math.max(maxSize, line.length);
|
||||
sizes.push(line.length);
|
||||
} else {
|
||||
sizes.push(0);
|
||||
}
|
||||
});
|
||||
|
||||
maxSize += 3;
|
||||
|
||||
return function(index) {
|
||||
return Array(maxSize - sizes[index]).join(' ');
|
||||
};
|
||||
}
|
||||
|
||||
function getLinesContainingOnlyBranches(tree) {
|
||||
tree.nodes.forEach(function(node) {
|
||||
node.label = '';
|
||||
node.opts.forEach(function() {
|
||||
node.label += '\n';
|
||||
});
|
||||
});
|
||||
|
||||
return archy(tree)
|
||||
.split('\n')
|
||||
.slice(1, -1);
|
||||
}
|
||||
|
||||
function printTreeList(lines, spacer, lineInfos) {
|
||||
lines.forEach(function(branch, index) {
|
||||
var info = lineInfos[index];
|
||||
|
||||
var line = ansi.white(branch);
|
||||
|
||||
if (info.type === 'top') {
|
||||
line += ansi.cyan(info.name);
|
||||
if (info.desc.length > 0) {
|
||||
line += spacer(index) + ansi.white(info.desc);
|
||||
}
|
||||
} else if (info.type === 'option') {
|
||||
line += ansi.magenta(info.name);
|
||||
if (info.desc.length > 0) {
|
||||
line += spacer(index) + ansi.white('…' + info.desc);
|
||||
}
|
||||
} else { // If (info.type === 'child') {
|
||||
line += ansi.white(info.name);
|
||||
}
|
||||
|
||||
log.info(line);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = logTasks;
|
||||
|
58
node_modules/gulp-cli/lib/shared/log/to-console.js
generated
vendored
Normal file
58
node_modules/gulp-cli/lib/shared/log/to-console.js
generated
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
|
||||
var fancyLog = require('fancy-log');
|
||||
|
||||
/* istanbul ignore next */
|
||||
function noop() {}
|
||||
|
||||
// The sorting of the levels is
|
||||
// significant.
|
||||
var levels = [
|
||||
'error', // -L: Logs error events.
|
||||
'warn', // -LL: Logs warn and error events.
|
||||
'info', // -LLL: Logs info, warn and error events.
|
||||
'debug', // -LLLL: Logs all log levels.
|
||||
];
|
||||
|
||||
function cleanup(log) {
|
||||
levels.forEach(removeListeners);
|
||||
|
||||
function removeListeners(level) {
|
||||
if (level === 'error') {
|
||||
log.removeListener(level, noop);
|
||||
log.removeListener(level, fancyLog.error);
|
||||
} else {
|
||||
log.removeListener(level, fancyLog);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toConsole(log, opts) {
|
||||
// Remove previous listeners to enable to call this twice.
|
||||
cleanup(log);
|
||||
|
||||
// Return immediately if logging is
|
||||
// not desired.
|
||||
if (opts.tasksSimple || opts.tasksJson || opts.help || opts.version || opts.silent) {
|
||||
// Keep from crashing process when silent.
|
||||
log.on('error', noop);
|
||||
return;
|
||||
}
|
||||
|
||||
// Default loglevel to info level (3).
|
||||
var loglevel = opts.logLevel || 3;
|
||||
|
||||
levels
|
||||
.filter(function(item, i) {
|
||||
return i < loglevel;
|
||||
})
|
||||
.forEach(function(level) {
|
||||
if (level === 'error') {
|
||||
log.on(level, fancyLog.error);
|
||||
} else {
|
||||
log.on(level, fancyLog);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = toConsole;
|
28
node_modules/gulp-cli/lib/shared/log/verify.js
generated
vendored
Normal file
28
node_modules/gulp-cli/lib/shared/log/verify.js
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
var log = require('gulplog');
|
||||
|
||||
var ansi = require('../ansi');
|
||||
var exit = require('../exit');
|
||||
|
||||
function logVerify(blacklisted) {
|
||||
var pluginNames = Object.keys(blacklisted);
|
||||
|
||||
if (!pluginNames.length) {
|
||||
log.info(
|
||||
ansi.green('There are no blacklisted plugins in this project')
|
||||
);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
log.warn(ansi.red('Blacklisted plugins found in this project:'));
|
||||
|
||||
pluginNames.map(function(pluginName) {
|
||||
var reason = blacklisted[pluginName];
|
||||
log.warn(ansi.bgred(pluginName) + ': ' + reason);
|
||||
});
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
module.exports = logVerify;
|
11
node_modules/gulp-cli/lib/shared/make-title.js
generated
vendored
Normal file
11
node_modules/gulp-cli/lib/shared/make-title.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
function makeTitle(cmd, argv) {
|
||||
if (!argv || argv.length === 0) {
|
||||
return cmd;
|
||||
}
|
||||
|
||||
return [cmd].concat(argv).join(' ');
|
||||
}
|
||||
|
||||
module.exports = makeTitle;
|
21
node_modules/gulp-cli/lib/shared/register-exports.js
generated
vendored
Normal file
21
node_modules/gulp-cli/lib/shared/register-exports.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
function registerExports(gulpInst, tasks) {
|
||||
var taskNames = Object.keys(tasks);
|
||||
|
||||
if (taskNames.length) {
|
||||
taskNames.forEach(register);
|
||||
}
|
||||
|
||||
function register(taskName) {
|
||||
var task = tasks[taskName];
|
||||
|
||||
if (typeof task !== 'function') {
|
||||
return;
|
||||
}
|
||||
|
||||
gulpInst.task(task.displayName || taskName, task);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = registerExports;
|
32
node_modules/gulp-cli/lib/shared/require-or-import.js
generated
vendored
Normal file
32
node_modules/gulp-cli/lib/shared/require-or-import.js
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
'use strict';
|
||||
|
||||
var pathToFileURL = require('url').pathToFileURL;
|
||||
|
||||
var importESM;
|
||||
try {
|
||||
// Node.js <10 errors out with a SyntaxError when loading a script that uses import().
|
||||
// So a function is dynamically created to catch the SyntaxError at runtime instead of parsetime.
|
||||
// That way we can keep supporting all Node.js versions all the way back to 0.10.
|
||||
importESM = new Function('id', 'return import(id);');
|
||||
} catch (e) {
|
||||
importESM = null;
|
||||
}
|
||||
|
||||
function requireOrImport(path, callback) {
|
||||
var err = null;
|
||||
var cjs;
|
||||
try {
|
||||
cjs = require(path);
|
||||
} catch (e) {
|
||||
if (pathToFileURL && importESM && e.code === 'ERR_REQUIRE_ESM') {
|
||||
// This is needed on Windows, because import() fails if providing a Windows file path.
|
||||
var url = pathToFileURL(path);
|
||||
importESM(url).then(function(esm) { callback(null, esm); }, callback);
|
||||
return;
|
||||
}
|
||||
err = e;
|
||||
}
|
||||
process.nextTick(function() { callback(err, cjs); });
|
||||
}
|
||||
|
||||
module.exports = requireOrImport;
|
9
node_modules/gulp-cli/lib/shared/tildify.js
generated
vendored
Normal file
9
node_modules/gulp-cli/lib/shared/tildify.js
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var replaceHomedir = require('replace-homedir');
|
||||
|
||||
function tildify(filepath) {
|
||||
return replaceHomedir(filepath, '~');
|
||||
}
|
||||
|
||||
module.exports = tildify;
|
25
node_modules/gulp-cli/lib/shared/verify-dependencies.js
generated
vendored
Normal file
25
node_modules/gulp-cli/lib/shared/verify-dependencies.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
var matchdep = require('matchdep');
|
||||
|
||||
/**
|
||||
* Given a collection of plugin names verifies this collection against
|
||||
* the blacklist. Returns an object with:
|
||||
* [plugin name]=>[blacklisting reason]
|
||||
* or an empty object if none of the dependencies to check are blacklisted.
|
||||
*
|
||||
* @param pkg - package.json contents
|
||||
* @param blacklist - contents of the blacklist in JSON format
|
||||
*/
|
||||
function verifyDependencies(pkg, blacklist) {
|
||||
var blacklisted = matchdep
|
||||
.filterAll(Object.keys(blacklist), pkg)
|
||||
.reduce(function(blacklisted, pluginName) {
|
||||
blacklisted[pluginName] = blacklist[pluginName];
|
||||
return blacklisted;
|
||||
}, {});
|
||||
|
||||
return blacklisted;
|
||||
}
|
||||
|
||||
module.exports = verifyDependencies;
|
Reference in New Issue
Block a user