mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-01-25 18:46:17 +00:00
clear utils
This commit is contained in:
parent
a6ff3b4f62
commit
1d44b9e2b2
@ -3,7 +3,7 @@
|
||||
var spawn = require('child_process').spawn,
|
||||
ParentCommand = require('./base').Command,
|
||||
inherits = require('util').inherits,
|
||||
utils = require('../utils');
|
||||
_ = require('underscore');
|
||||
|
||||
function Command(params) {
|
||||
params = params || {};
|
||||
@ -24,7 +24,7 @@ Command.prototype.run = function(params, callback) {
|
||||
|
||||
if (!params.cmd) return callback(new Error('`cmd` is not set'));
|
||||
if (!params.args) return callback(new Error('`args` is not set'));
|
||||
callback = utils.once(callback);
|
||||
callback = _(callback).once();
|
||||
params.options = params.options || {};
|
||||
params.options.cwd = params.options.cwd || this.cwd;
|
||||
|
||||
|
23
lib/utils.js
23
lib/utils.js
@ -1,28 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
['Function', 'String', 'Number', 'Date', 'RegExp'].forEach(function(name) {
|
||||
exports['is' + name] = function(obj) {
|
||||
return toString.call(obj) == '[object ' + name + ']';
|
||||
};
|
||||
});
|
||||
|
||||
exports.isObject = function(obj) {
|
||||
return obj === Object(obj);
|
||||
};
|
||||
|
||||
exports.noop = function() {};
|
||||
|
||||
exports.slice = Array.prototype.slice;
|
||||
|
||||
exports.once = function(func) {
|
||||
var isCalled = false;
|
||||
return function() {
|
||||
if (isCalled) return;
|
||||
func.apply(this, arguments);
|
||||
isCalled = true;
|
||||
};
|
||||
};
|
||||
|
||||
exports.prune = function(str, length) {
|
||||
var result = '',
|
||||
words = str.split(' ');
|
||||
|
Loading…
Reference in New Issue
Block a user