appc-compat
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -6,3 +6,3 @@ 'use strict'; | ||
exports.async = function async(cmd, callback) { | ||
spawn.async('which', [cmd], null, function (err, stdout, stderr) { | ||
spawn.async(process.platform === 'win32' ? 'where' : 'which', [cmd], null, function (err, out, code) { | ||
callback(!err); | ||
@@ -9,0 +9,0 @@ }); |
@@ -9,54 +9,58 @@ 'use strict'; | ||
if (process.platform === 'win32') { | ||
args = ['/c', cmd].concat(args); | ||
cmd = process.env.comspec; | ||
} | ||
if (process.platform === 'win32') { | ||
args = ['/c', cmd].concat(args); | ||
cmd = process.env.comspec; | ||
} | ||
var childProcess = child_process.spawn(cmd, args, opts || {}); | ||
var child = child_process.spawn(cmd, args, opts || {}); | ||
if (callback) { | ||
var stdout = ''; | ||
var stderr = ''; | ||
if (callback) { | ||
var stdout = ''; | ||
var stderr = ''; | ||
// null if cmd does not exist | ||
childProcess.stdout && childProcess.stdout.on('data', function (data) { | ||
stdout += data.toString(); | ||
}); | ||
// null if cmd does not exist | ||
if (child.stdout) { | ||
child.stdout.on('data', function(data) { | ||
stdout += data.toString(); | ||
}); | ||
} | ||
// null if cmd does not exist | ||
childProcess.stderr && childProcess.stderr.on('data', function (data) { | ||
stderr += data.toString(); | ||
}); | ||
// null if cmd does not exist | ||
if (child.stderr) { | ||
child.stderr.on('data', function(data) { | ||
stderr += data.toString(); | ||
}); | ||
} | ||
childProcess.on('close', function (code) { | ||
callback(code !== 0, stdout, stderr); | ||
}); | ||
child.on('close', function(code) { | ||
callback(stderr, stdout, code); | ||
}); | ||
// fired when cmd does not exist, throwing exception when not listened to | ||
childProcess.on('error', function (err) { | ||
callback(err, stdout, stderr); | ||
}); | ||
} | ||
// fired when cmd does not exist, throwing exception when not listened to | ||
child.on('error', function(err) { | ||
callback(err); | ||
}); | ||
} | ||
return childProcess; | ||
return child; | ||
}; | ||
exports.sync = function sync(cmd, args, opts) { | ||
var done = false; | ||
var res; | ||
var done = false; | ||
var res; | ||
exports.async(cmd, args, opts, function () { | ||
done = true; | ||
res = Array.prototype.slice.call(arguments); | ||
}); | ||
exports.async(cmd, args, opts, function() { | ||
done = true; | ||
res = Array.prototype.slice.call(arguments); | ||
}); | ||
deasync.loopWhile(function () { | ||
return !done; | ||
}); | ||
deasync.loopWhile(function() { | ||
return !done; | ||
}); | ||
if (res[0]) { | ||
throw res[2]; | ||
} | ||
if (res[0]) { | ||
throw res[2]; | ||
} | ||
return res[1]; | ||
return res[1]; | ||
}; |
{ | ||
"name": "appc-compat", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Intermediator for the new Appcelerator \"appc\" CLI and the old \"ti\", \"alloy\" and \"acs\" CLI.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,2 @@ | ||
# Appcelerator CLI Compatability | ||
# Appcelerator CLI Compatibility | ||
@@ -16,3 +16,3 @@ Since 4.0, the Appcelerator Platform has a single [`appc`](http://docs.appcelerator.com/platform/latest/#!/guide/Appcelerator_Command-Line_Interface_Reference) CLI that bundles local versions of the former [`ti`](https://npmjs.com/titanium), [`alloy`](https://npmjs.com/alloy) and [`acs`](https://npmjs.com/acs) CLI. You can still use the embedded CLIs by calling `appc ti` instead of `ti`. You can also still install the other three CLIs directly from NPM, in particular to work on projects that you have not (yet) migrated from the OSS software to the Appcelerator Platform. | ||
// options | ||
}, funciton(err, stdout, stderr) { | ||
}, function(err, out, code) { | ||
// do something | ||
@@ -25,3 +25,3 @@ }); | ||
* `compat.spawn(cmd, args, opts, cb);` | ||
* `compat.spawnSync(cmd, args, opts);` | ||
* `compat.spawnSync(cmd, args, opts);` | ||
* `compat.tiSync(args, opts);` | ||
@@ -70,2 +70,2 @@ * `compat.titanium(args, opts, cb);` | ||
source ~/.bash_profile | ||
``` | ||
``` |
8392
9
155
69