-
-
Save anonymous/9299898 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var util = require('util'), | |
fs = require('fs'), | |
path = require('path'), | |
http = require('http'), | |
_ = require('lodash'), | |
url = require('url'); | |
var DEBUG = false, | |
host = 'http://127.0.0.1:8888/'; | |
if (!module.parent) { | |
/* | |
1. get some info from package.json | |
2. run cfx | |
3. on completion, post the xpi file to Firefox | |
*/ | |
var xpi = false; | |
var cwd = process.cwd(); | |
var spawn = require('child_process').spawn; | |
var optimist = require('optimist'); | |
var argv = optimist | |
.usage('addon-install -h http://localhost:888/') | |
.default({h: host}) | |
.describe('h', 'The host and port that the extension auto-installer is listening on') | |
.alias('p', 'port') | |
.argv; | |
fs.readFile(path.join(cwd, 'package.json'), | |
{encoding: 'utf8'}, | |
function(err, buffer) { | |
// | |
if (err) throw err; | |
// console.log(buffer); | |
var package_data = JSON.parse(buffer), | |
xpi_name = package_data.name + '.xpi'; | |
console.log("Building %s", xpi_name); | |
var builder = spawn('cfx', ['xpi'], {cwd: cwd}); | |
builder.stdout.on('data', function(data) { | |
console.log("cfx> %s", data); | |
}); | |
builder.stderr.on('data', function(data) { | |
console.log("cfx> %s", data); | |
}); | |
builder.on('error', function(err) { | |
console.log([].slice.call(arguments)); | |
}); | |
builder.on('close', function(err, result) { | |
post_file = spawn('wget', ['--post-file='+xpi_name, host], {cwd: cwd}); | |
post_file.stderr.on('data', function(data) { | |
console.log("wget> %s", data); | |
}); | |
post_file.stdout.on('data', function(data) { | |
console.log("wget> %s", data); | |
}); | |
post_file.on('close', function(err, result) { | |
console.log("done?"); | |
}); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment