neutron-adt
Version:
Neutron Atomic Design Tool
64 lines (52 loc) • 1.54 kB
JavaScript
var pkg = require('../../package.json');
var path = require('path');
var util = require('util');
var args = process.argv;
var isTest = args.indexOf('-t') > -1;
module.exports = {
log: function (message, type) {
var types = {
title: '\x1b[45m',
info: '\x1b[33m',
error: '\x1b[31m',
success: '\x1b[32m'
},
reset = '\x1b[0m',
color = reset;
if (type) {
color = types[type];
}
if (type === 'title') {
console.log('');
}
console.log(color, message, reset);
if (type === 'title') {
console.log('');
}
},
getPath: function (dir, filename) {
if (!dir) {
throw("A directory is not defined. Please, check if all paths are defined in your neutron.json file. Check https://github.com/vebersol/neutron/blob/" +pkg.version + "/neutron.json for more information.");
}
if (filename) {
return path.resolve(__dirname, '../../', dir + filename);
}
return path.resolve(__dirname, '../../', dir);
},
getAppPath: function (dir, filename) {
if (!dir) {
throw("A directory is not defined. Please, check if all paths are defined in your neutron.json file. Check https://github.com/vebersol/neutron/blob/" + pkg.version + "/neutron.json for more information.");
}
if (filename) {
return path.resolve(process.cwd(), dir + filename);
}
return path.resolve(process.cwd(), dir);
}
}
// Extend some methods to native functions
Array.prototype.removeDuplicates = function () {
var a = this;
return a.filter(function(item, pos) {
return a.indexOf(item) == pos;
});
}