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

grunt-glue-js

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-glue-js - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

0

CONTRIBUTING.md
Please see the [Contributing to grunt](http://gruntjs.com/contributing) guide for information on contributing to this project.

9

Gruntfile.js

@@ -36,12 +36,11 @@ /*

directory: {
options: {
main: 'main.js'
},
src: 'test/fixtures/package/*.js',
dest: 'test/fixtures/index.js'
},
ignore: {
src: 'test/fixtures/package/*.js',
dest: 'test/fixtures/index.js'
},
export_and_basepath: {
options: {
export: 'App',
export: 'MyApp',
basepath: 'test/fixtures/package'

@@ -48,0 +47,0 @@ },

{
"name": "grunt-glue-js",
"description": "Grunt task to build CommonJS modules for the browser using gluejs.",
"version": "0.0.4",
"version": "0.0.5",
"homepage": "https://github.com/ngryman/grunt-glue-js",

@@ -34,3 +34,3 @@ "author": {

"dependencies": {
"gluejs": "~0.2.2"
"gluejs": "~2.3.7"
},

@@ -37,0 +37,0 @@ "devDependencies": {

@@ -52,3 +52,4 @@ # grunt-glue-js [![Build Status](https://travis-ci.org/ngryman/grunt-glue-js.png?branch=master)](https://travis-ci.org/ngryman/grunt-glue-js)

options: {
export: 'App'
export: 'App',
main: 'public/scripts/index.js'
},

@@ -62,4 +63,30 @@ src: 'public/scripts/**/*.js',

#### Advanced
In this example, we use `coffeeify` to package our CoffeeScript app. We also showcase some more options.
```javascript
// Project configuration.
grunt.initConfig({
gluejs: {
app: {
options: {
export: 'App',
report: true,
debug: true,
transform: 'coffeeify',
replace: {
jQuery: 'window.jQuery'
},
main: 'public/scripts/index.coffee'
},
src: 'public/scripts/**/*.coffee',
dest: 'public/app.js'
}
}
});
```
## Release History
* 2014-04-07   v0.0.5   Switch to `gluejs` v2 (2.3.7).
* 2013-12-10   v0.0.4   Set `gluejs` as an `npm` dep as requested fixes are now released.

@@ -66,0 +93,0 @@ * 2013-05-24   v0.0.3   `basepath` and `main` options support.

@@ -17,13 +17,20 @@ /*

// merges task-specific and/or target-specific options with these defaults.
var done = this.async();
var options = this.options({
stripBanners: false,
process: false
cache: false,
require: false,
report: false,
debug: false
});
// normalizes boolean options that accept options objects.
if (options.stripBanners === true) { options.stripBanners = {}; }
if (options.process === true) { options.process = {}; }
var n_todo = 0;
var n_done = 0;
var n_err = 0;
var n_files = this.files.length;
// default options for glue
Glue.defaults(options);
if (!(options.main || ((n_files == 1) && (this.files[0].src.length == 1)))) {
grunt.fail.fatal("The `main` option to gluejs is mandatory when there is more than one source file.");
return;
}

@@ -36,26 +43,112 @@ // processes banner and footer.

this.files.forEach(function(file) {
n_todo = n_todo + 1;
var glue = new Glue();
// export
if (options.export) { glue.export(options.export); }
if (options.debug) {
grunt.log.writeln("processing file '" + file.src + "'");
}
if (options.cache !== null) {
glue.set('cache', options.cache);
}
if (options.require !== null) {
glue.set('require', options.require);
}
if (options.report !== null) {
glue.set('report', options.report);
}
//glue.set('cache', false).set('require', false).set('report', true);
// command
if (options.command) {
glue.set('command', options.command);
}
// transform
if (options.transform) {
glue.options['transform'] = options.transform;
}
// basepath
// TODO: should work with defaults
if (options.basepath) { glue.basepath(options.basepath); }
if (options.basepath) {
// output paths are relative to this
glue.basepath(options.basepath);
}
else {
// output paths are relative to this
glue.basepath(process.cwd());
}
// includes source files - excludes the destination file if it is in the same directory of source(s) file(s)
file.src.forEach(function(src) {
var relpath = src;
if (options.basepath)
relpath = path.relative(options.basepath, relpath);
if (options.debug) {
grunt.log.writeln("including '" + src + "' as '" + relpath + "'");
}
if (src !== file.dest) {
glue.include(src);
// includes all files in the dir
glue.include(relpath);
}
});
// exclude
if (options.exclude) {
glue.exclude(options.exclude);
}
if (options.main) {
// the file that's exported as the root of the package
glue.main(options.main);
}
else if ((n_files == 1) && (file.src.length == 1)) {
var relpath = file.src[0];
if (options.basepath)
relpath = path.relative(options.basepath, relpath);
glue.main(relpath);
}
// export
if (options.export) {
glue.export(options.export);
}
// replace
if (options.replace) {
var obj = options.replace;
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
glue.replace(key, obj[key]);
}
}
}
if (options.debug) {
grunt.log.writeln("going to render to '" + file.dest + "'");
console.log(glue);
}
glue.render(function(err, output) {
output = banner + output + footer;
grunt.file.write(file.dest, output);
if (err) {
grunt.log.writeln("error:", err);
grunt.warn.writeln('File "' + file.dest + '" NOT created.');
grunt.log.writeln('File "' + file.dest + '" created.');
n_err++;
}
else {
output = banner + output + footer;
grunt.file.write(file.dest, output);
grunt.log.writeln('File "' + file.dest + '" created.');
}
n_done++;
if (n_todo === n_done) {
// All done!
done((n_err === 0));
}
});
});
});
};
};

Sorry, the diff of this file is not supported yet

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