gulp-io
Version:
iio's front-end build tools.
42 lines (41 loc) • 1.24 kB
JavaScript
// DEPENDENCIES
var clc = require('cli-color');
// EXPORTS DEFINITION
var exports = module.exports = {};
// METHODS
// METHODS | GET CURRENT PROJECT
exports.project = function(gulp) {
return process.env.INIT_CWD;
};
// METHODS | GET ENVIRONMENT
exports.mode = function() {
if (process.argv[2] && process.argv[2].split("--")[1]) {
var env = process.argv[2].split("--")[1];
this.log('Environment: ' + env, 'success');
return env;
} else {
this.log('Environment: NONE', 'notice');
return '';
}
};
// METHODS | GET SCOPE
exports.scope = function(mode) {
if(mode && (mode === 'prod' || mode === 'production')){
return ['dependencies'];
}else{
return ['dependencies', mode + 'Dependencies'];
}
};
// METHODS | LOG
exports.log = function(message, type) {
this.error = clc.xterm(124).bold;
this.success = clc.xterm(40).bold;
this.warning = clc.xterm(214).bold;
this.notice = clc.xterm(60).bold;
this.info = clc.xterm(38).bold;
this.text = clc.xterm(255);
console.log('[' + this[type]("SB") + '] ' + clc.white.bold("-> ") + this[type](message.toString().replace("Error: ", "")));
if(type === 'error'){
process.exit(code=0);
}
};