Integrate windosu

This commit is contained in:
Juan Cruz Viotti 2015-01-29 12:04:48 -04:00
parent 7949296cec
commit 9069b07d4a
4 changed files with 30 additions and 4 deletions

View File

@ -1,5 +1,5 @@
#!/usr/bin/env node #!/usr/bin/env node
// http://coffeescript.org/documentation/docs/register.html // http://coffeescript.org/documentation/docs/register.html
require('coffee-script/register') require('coffee-script/register');
require('../lib/app.coffee') require('../lib/app.coffee');

16
bin/resin-write Normal file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env node
// http://coffeescript.org/documentation/docs/register.html
require('coffee-script/register');
var device = require('../lib/actions/device.coffee');
var errors = require('../lib/errors/errors');
device.init.action({
image: process.argv[2],
device: process.argv[3]
}, {
yes: true
}, function(error) {
return errors.handle(error);
});

View File

@ -1,4 +1,5 @@
_ = require('lodash-contrib') _ = require('lodash-contrib')
path = require('path')
async = require('async') async = require('async')
resin = require('resin-sdk') resin = require('resin-sdk')
os = require('os') os = require('os')
@ -165,7 +166,7 @@ exports.init =
options: [ commandOptions.yes ] options: [ commandOptions.yes ]
permission: 'user' permission: 'user'
action: (params, options, done) -> action: (params, options, done) ->
async.waterfall([ async.waterfall [
(callback) -> (callback) ->
if options.yes if options.yes
@ -186,5 +187,11 @@ exports.init =
progressBar.tick(status.delta) progressBar.tick(status.delta)
, callback , callback
], done) ], (error) ->
return done(error) if os.platform() isnt 'win32'
windosu = require('windosu')
# Need to escape everypath to avoid errors
resinWritePath = "\"#{path.join(__dirname, '..', '..', 'bin', 'resin-write')}\""
windosu.exec("node #{resinWritePath} \"#{params.image}\" \"#{params.device}\"").then ->
console.log 'Done'

View File

@ -26,6 +26,9 @@
], ],
"author": "Juan Cruz Viotti <juanchiviotti@gmail.com>", "author": "Juan Cruz Viotti <juanchiviotti@gmail.com>",
"license": "MIT", "license": "MIT",
"optionalDependencies": {
"windosu": "^0.1.3"
},
"devDependencies": { "devDependencies": {
"chai": "~1.9.2", "chai": "~1.9.2",
"gulp": "~3.8.9", "gulp": "~3.8.9",