Skip to content

Commit

Permalink
fixed the spawning of 'pack.sh' to be relative.
Browse files Browse the repository at this point in the history
  • Loading branch information
itayco committed Aug 23, 2012
1 parent 8a84c26 commit 3625293
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/crx.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var fs = require("fs")
, join = require("path").join
, path = require('path')
, join = path.join
, crypto = require("crypto")
, child = require("child_process")
, spawn = child.spawn
Expand All @@ -12,6 +13,7 @@ require('buffertools');

module.exports = new function() {
function ChromeExtension(attrs) {
console.log('T.Z:', __dirname);
if (this instanceof ChromeExtension) {
for (var name in attrs) this[name] = attrs[name];

Expand Down Expand Up @@ -79,14 +81,15 @@ module.exports = new function() {
*/
this._writeCrx = function (callback) {
var pemFilename = this.path+'.pem',
packerPath = path.resolve(__dirname+'/../pack.sh'),
packer,
crxFilename;

//1. save the private key to a PEM file
fs.writeFileSync(pemFilename, this.privateKey);

//2. execute pack.sh with /tmp
packer = spawn('./pack.sh', [this.path, pemFilename, '/tmp']);
packer = spawn(packerPath, [this.path, pemFilename, '/tmp']);
packer.stdout.on('data', function (filename) {
//3. collect the written CRX filename
crxFilename = filename.toString();
Expand All @@ -103,7 +106,7 @@ module.exports = new function() {
if (exitCode !== 0)
return callback('The CRX packer exited with erroneous code: ' + exitCode);

//5. callback the CRX filename
//5. callback with the CRX filename
callback(null, crxFilename);
});
};
Expand Down

0 comments on commit 3625293

Please sign in to comment.