Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt-mozilla-addon-sdk

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-mozilla-addon-sdk - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

scripts/cfx.bat

14

Gruntfile.js

@@ -33,3 +33,3 @@ /*

'mozilla-addon-sdk': {
download: {}, // use defaults
download: { options: { revision: "1.14" } }, // use 1.14 tag
xpi: {

@@ -43,2 +43,12 @@ options: {

// custom cfx command run
'mozilla-cfx': {
custom_cmd: {
options: {
extension_dir: "test/fixtures/test-addon",
command: 'test'
}
}
},
// Unit tests.

@@ -61,3 +71,3 @@ nodeunit: {

// plugin's task(s), then test the result.
grunt.registerTask('test', ['clean', 'mozilla-addon-sdk', 'nodeunit']);
grunt.registerTask('test', ['clean', 'mozilla-addon-sdk', 'mozilla-cfx', 'nodeunit']);

@@ -64,0 +74,0 @@ // By default, lint and run all tests.

{
"name": "grunt-mozilla-addon-sdk",
"description": "Download and Run Mozilla Addon SDK",
"version": "0.1.0",
"version": "0.2.0",
"homepage": "https://github.com/rpl/grunt-mozilla-addon-sdk",

@@ -11,2 +11,7 @@ "author": {

},
"contributors": [
{
"name": "Oleg Shevchenko (https://github.com/olsh)"
}
],
"repository": {

@@ -13,0 +18,0 @@ "type": "git",

@@ -30,3 +30,3 @@ # grunt-mozilla-addon-sdk

options: {
revision: "firefox26"
revision: "1.14"
},

@@ -40,3 +40,21 @@ }

},
}
});
Custom cfx command could be defined using a section named `mozilla-cfx`:
```js
grunt.initConfig({
"mozilla-addon-sdk": {
...
},
"mozilla-cfx": {
custom_command: {
options: {
extension_dir: "ff_extension",
command: "run",
arguments: "-b /usr/bin/firefox-nightly"
}
}
}
})

@@ -91,2 +109,3 @@ ```

- 0.2.0 - added windows support and custom cfx command using 'mozilla-cfx' grunt multi-task
- 0.1.0 - initial release (download and xpi sub-tasks)

101

tasks/mozilla_addon_sdk.js

@@ -28,2 +28,3 @@ /*

options: {
arguments: null,
extension_dir: null

@@ -34,9 +35,8 @@ }

function xpi(grunt, options) {
function cfx(grunt, ext_dir, cfx_cmd, cfx_args) {
var sdk_dir = path.resolve(grunt.config('mozilla-addon-sdk').download.options.dest_dir,
"addon-sdk");
var ext_dir = path.resolve(options.extension_dir);
var dist_dir = path.resolve(options.dist_dir);
var completed = Q.defer();
var xpi_script = path.resolve(__dirname, '..', 'scripts', 'xpi.sh');
var scriptFilename = process.platform.match(/^win/) ? 'cfx.bat' : 'cfx.sh';
var xpi_script = path.resolve(__dirname, '..', 'scripts', scriptFilename);

@@ -51,4 +51,2 @@ var package_json = path.resolve(ext_dir, "package.json");

if (error) {
grunt.log.error(error);
grunt.fail.warn('There was an error while generating xpi.');
completed.reject(error);

@@ -58,2 +56,32 @@ return completed.promise;

grunt.log.debug(["Running cfx", cfx_cmd, cfx_args].join(' '));
var args = [
sdk_dir,
ext_dir,
cfx_cmd
];
if (cfx_args) args.push(cfx_args);
grunt.util.spawn({
cmd: xpi_script,
opts: grunt.option("debug") ? {stdio: 'inherit'} : {},
args: args,
}, function (error, result, code) {
if (error) {
completed.reject(error);
} else {
completed.resolve();
}
});
return completed.promise;
}
function xpi(grunt, options) {
var ext_dir = path.resolve(options.extension_dir);
var dist_dir = path.resolve(options.dist_dir);
var cfx_args = options.arguments;
var completed = Q.defer();
grunt.log.writeln("Creating dist dir '" + dist_dir + "'...");

@@ -65,15 +93,4 @@

grunt.util.spawn({
cmd: xpi_script,
args: [
sdk_dir,
ext_dir
],
opts: []
}, function (error, result, code) {
if (error) {
grunt.log.error(error);
grunt.fail.warn('There was an error while generating xpi.');
completed.reject(error);
} else {
cfx(grunt, ext_dir, "xpi", cfx_args).
then(function () {
var xpi_files = grunt.file.expand(options.extension_dir + "/*.xpi");

@@ -83,4 +100,2 @@

var no_xpi_error = new Error("no xpi found");
grunt.log.error(no_xpi_error);
grunt.fail.warn('There was an error while generating xpi.');
completed.reject(no_xpi_error);

@@ -94,7 +109,13 @@ return;

var dist_xpi = path.resolve(dist_dir, path.basename(xpi_files[0]));
mv(path.resolve(xpi_files[0]),
path.resolve(dist_dir, path.basename(xpi_files[0])),
completed.resolve);
}
});
dist_xpi,
function () {
grunt.log.writeln("Generated XPI:", dist_xpi);
completed.resolve();
});
}).
catch(function (error) {
completed.reject(error);
});

@@ -176,3 +197,8 @@ return completed.promise;

case "download":
download(grunt, options).then(done);
download(grunt, options).
then(done).
catch(function (error) {
grunt.fail.warn('There was an error running mozilla-addon-sdk:download. ' + error);
done();
});
break;

@@ -182,6 +208,27 @@ case "xpi":

grunt.config.requires("mozilla-addon-sdk.xpi.options.dist_dir");
xpi(grunt, options).then(done);
xpi(grunt, options).
then(done).
catch(function (error) {
grunt.fail.warn('There was an error running mozilla-addon-sdk:xpi. ' + error);
done();
});
break;
}
});
grunt.registerMultiTask('mozilla-cfx', 'Run Mozilla Addon SDK command line tool', function() {
var options = this.options();
var done = this.async();
grunt.config.requires(["mozilla-cfx",this.target,"options","extension_dir"].join('.'));
grunt.config.requires(["mozilla-cfx",this.target,"options","command"].join('.'));
cfx(grunt, path.resolve(options.extension_dir),
options.command, options.arguments).
then(done).
catch(function (error) {
grunt.fail.warn('There was an error running mozilla-cfx. ' + error);
done();
});
});
};

@@ -48,3 +48,10 @@ 'use strict';

test.done();
},
custom_cmd: function(test) {
test.expect(1);
var test_result_file = path.resolve("tmp", "test_run.txt");
test.ok(grunt.file.exists(test_result_file), "grunt mozilla-cfx:custom_cmd should run addon unit tests");
test.done();
}
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc