closure-util
Advanced tools
Comparing version 0.11.0 to 0.12.0
@@ -85,3 +85,3 @@ Options for the Closure Compiler: | ||
undefinedVars, unknownDefines, | ||
uselessCode, visibility | ||
uselessCode, googBase, visibility | ||
--jscomp_off VAL : Turn off the named class of warnings. | ||
@@ -103,3 +103,3 @@ Options:accessControls, ambiguousFunct | ||
undefinedVars, unknownDefines, | ||
uselessCode, visibility | ||
uselessCode, googBase, visibility | ||
--jscomp_warning VAL : Make the named class of warnings a | ||
@@ -121,4 +121,4 @@ normal warning. Options:accessControls | ||
, undefinedNames, undefinedVars, | ||
unknownDefines, uselessCode, visibilit | ||
y | ||
unknownDefines, uselessCode, googBase, | ||
visibility | ||
--language_in VAL : Sets what language spec that input | ||
@@ -212,5 +212,5 @@ sources conform. Options: ECMASCRIPT3 | ||
should be saved | ||
--source_map_format [V1 | DEFAULT | : The source map format to produce. | ||
V2 | V3] : Options: V1, V2, V3, DEFAULT. DEFAULT | ||
produces V2. | ||
--source_map_format [DEFAULT | V3] : The source map format to produce. | ||
Options are V3 and DEFAULT, which are | ||
equivalent. | ||
--summary_detail_level N : Controls how detailed the compilation | ||
@@ -263,2 +263,2 @@ summary is. Values: 0 (never print | ||
Current for http://dl.google.com/closure-compiler/compiler-20140303.zip | ||
Current for http://dl.google.com/closure-compiler/compiler-20140407.zip |
{ | ||
"compiler_url": "http://dl.google.com/closure-compiler/compiler-20140303.zip", | ||
"compiler_url": "http://dl.google.com/closure-compiler/compiler-20140407.zip", | ||
"library_url": "https://closure-library.googlecode.com/archive/ab89cf45c216615d73a2f5dea720afb9d3415d1f.zip", | ||
"log_level": "info" | ||
} |
@@ -140,2 +140,3 @@ var EventEmitter = require('events').EventEmitter; | ||
var base = []; | ||
var depsOnly = []; | ||
Object.keys(scriptsLookup).forEach(function(name) { | ||
@@ -154,2 +155,6 @@ var script = scriptsLookup[name]; | ||
}); | ||
if (script.provides.length === 0 && script.requires.length === 0 && | ||
script.addsDependencies) { | ||
depsOnly.push(script); | ||
} | ||
}); | ||
@@ -204,2 +209,5 @@ | ||
} | ||
if (depsOnly.length > 0) { | ||
dependencies = dependencies.concat(depsOnly); | ||
} | ||
this._dependencies[mainKey] = dependencies; | ||
@@ -206,0 +214,0 @@ } |
@@ -138,3 +138,56 @@ var path = require('path'); | ||
/** | ||
* Statement with goog.addDependency call. | ||
* @type {Object} | ||
*/ | ||
var addDependencyNode = { | ||
type: 'ExpressionStatement', | ||
start: '*', | ||
end: '*', | ||
expression: { | ||
type: 'CallExpression', | ||
start: '*', | ||
end: '*', | ||
callee: { | ||
type: 'MemberExpression', | ||
start: '*', | ||
end: '*', | ||
object: { | ||
type: 'Identifier', | ||
start: '*', | ||
end: '*', | ||
name: 'goog' | ||
}, | ||
property: { | ||
type: 'Identifier', | ||
start: '*', | ||
end: '*', | ||
name: 'addDependency' | ||
}, | ||
computed: false | ||
}, | ||
arguments: [ | ||
{ | ||
type: 'Literal', | ||
start: '*', | ||
end: '*', | ||
value: '*', | ||
raw: '*' | ||
}, { | ||
type: 'ArrayExpression', | ||
start: '*', | ||
end: '*', | ||
elements: '*' | ||
}, { | ||
type: 'ArrayExpression', | ||
start: '*', | ||
end: '*', | ||
elements: '*' | ||
} | ||
] | ||
} | ||
}; | ||
/** | ||
@@ -184,2 +237,8 @@ * Script constructor. | ||
/** | ||
* Adds dependencies. | ||
* @type {boolean} | ||
*/ | ||
this._addsDependencies = undefined; | ||
/** | ||
* Provides array. | ||
@@ -200,2 +259,24 @@ * @type {Array.<string>} | ||
/** | ||
* Determine if the script includes a call to goog.addDependency. | ||
* @return {boolean} The script includes a call to goog.addDependency. | ||
*/ | ||
Script.prototype._getAddsDependencies = function() { | ||
return this._ast.body.some(function(statement) { | ||
return like(statement, addDependencyNode); | ||
}); | ||
}; | ||
Object.defineProperty(Script.prototype, 'addsDependencies', { | ||
enumerable: true, | ||
get: function() { | ||
if (this._addsDependencies === undefined) { | ||
this._addsDependencies = this._getAddsDependencies(); | ||
} | ||
return this._addsDependencies; | ||
} | ||
}); | ||
/** | ||
* Get provides. | ||
@@ -202,0 +283,0 @@ * @return {Array.<string>} List of arguments to goog.provide calls. |
{ | ||
"name": "closure-util", | ||
"version": "0.11.0", | ||
"version": "0.12.0", | ||
"description": "Utilities for Closure Library based projects.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -5,2 +5,4 @@ # Closure Util | ||
[![Current Status](https://secure.travis-ci.org/openlayers/closure-util.png?branch=master)](https://travis-ci.org/openlayers/closure-util) | ||
## API | ||
@@ -12,3 +14,3 @@ | ||
* **config.lib** - `string|Array.<string>` A list of [path patterns](https://github.com/isaacs/minimatch) for your library scripts (e.g. `'lib/**/*.js'`). Note that path delimters in these patterns should always be forward slashes (even on Windows). | ||
* **config.lib** - `string|Array.<string>` A list of [path patterns](https://github.com/isaacs/minimatch) for your library scripts (e.g. `'lib/**/*.js'`). Note that path delimiters in these patterns should always be forward slashes (even on Windows). | ||
* **config.main** - `string|Array.<string>` Patterns for your main script(s). | ||
@@ -58,3 +60,3 @@ | ||
### <a id="compile">`compile(options, callback)`</a> | ||
### <a id="compile">`compile(options, [jvm], callback)`</a> | ||
@@ -69,3 +71,3 @@ The `compile` function drives the Closure Compiler. | ||
The `closure-util` package downloads the Closure Compiler and Closure Library when installed. To use a different version of these resources, you can provide some basic configuration options before running `npm install`. Your configuration options can come from a number of different sources. The most straightforward way is to include a `closure-util.json` file in your project. You can also provide configuration options via environemnt variables. Environment variables have the `closure_` prefix in front of the options described below (e.g. `closure_log_level` to specify the `log_level` option). | ||
The `closure-util` package downloads the Closure Compiler and Closure Library when installed. To use a different version of these resources, you can provide some basic configuration options before running `npm install`. Your configuration options can come from a number of different sources. The most straightforward way is to include a `closure-util.json` file in your project. You can also provide configuration options via environment variables. Environment variables have the `closure_` prefix in front of the options described below (e.g. `closure_log_level` to specify the `log_level` option). | ||
@@ -98,2 +100,13 @@ Available configuration options (see `default-config.json` for default values): | ||
[![Current Status](https://secure.travis-ci.org/openlayers/closure-util.png?branch=master)](https://travis-ci.org/openlayers/closure-util) | ||
## Publishing | ||
To publish a new version of the `closure-util` package, first create a tag, and then publish. Creating a tag can be done with the [`npm version` command](https://www.npmjs.org/doc/cli/npm-version.html). This is a handy way to update `package.json` and create a git tag named like the new version. The [`npm publish` command](https://www.npmjs.org/doc/cli/npm-publish.html) is used to publish the package to the [registry](https://www.npmjs.org/package/closure-util). | ||
Example of publishing a new minor version (to increment the major version or create a patch release, replace `minor` with `major` or `patch`). This assumes you have the latest from [`master`](https://github.com/openlayers/closure-util/tree/master) and your remote is named `openlayers`. | ||
```bash | ||
npm version minor | ||
git push --tags openlayers master && npm publish | ||
``` | ||
To publish a new version, you need to have [signed up](https://www.npmjs.org/signup) for an account with the registry. After signing up for an account, contact one of the current `closure-util` maintainers and ask to be added (with [`npm owner`](https://www.npmjs.org/doc/cli/npm-owner.html)). |
@@ -193,2 +193,22 @@ var path = require('path'); | ||
it('includes scripts with goog.addDependency calls', function(done) { | ||
var manager = new Manager({ | ||
closure: false, | ||
cwd: fixtures, | ||
lib: 'adds-deps/+(lib|goog)/**/*.js', | ||
main: 'adds-deps/main.js' | ||
}); | ||
manager.on('error', done); | ||
manager.on('ready', function() { | ||
var dependencies = manager.getDependencies( | ||
path.join(fixtures, 'adds-deps', 'main.js')); | ||
var names = dependencies.map(function(s) { | ||
return path.basename(s.name); | ||
}); | ||
assert.deepEqual(names, | ||
['base.js', 'math.js', 'main.js', 'deps.js']); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
@@ -195,0 +215,0 @@ |
@@ -61,2 +61,30 @@ var path = require('path'); | ||
describe('#addsDependencies', function() { | ||
it('is true for scripts with goog.addDependency calls', function(done) { | ||
var p = path.join(fixtures, 'adds-deps', 'goog', 'deps.js'); | ||
scripts.read(p, function(err, script) { | ||
if (err) { | ||
done(err); | ||
} else { | ||
assert.equal(script.addsDependencies, true); | ||
done(); | ||
} | ||
}); | ||
}); | ||
it('is false with no goog.addDependency calls', function(done) { | ||
var p = path.join(fixtures, 'adds-deps', 'main.js'); | ||
scripts.read(p, function(err, script) { | ||
if (err) { | ||
done(err); | ||
} else { | ||
assert.equal(script.addsDependencies, false); | ||
done(); | ||
} | ||
}); | ||
}); | ||
}); | ||
describe('#provides', function() { | ||
@@ -63,0 +91,0 @@ var script; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
83046
49
1873
108