closure-util
Advanced tools
Comparing version 0.12.0 to 0.13.0
@@ -0,13 +1,73 @@ | ||
/** | ||
* Previously, the config-chain package was used here. This failed on Node | ||
* 0.11 - see https://github.com/dominictarr/config-chain/issues/18. | ||
* | ||
* The find and getEnv functions below are adapted from config-chain. This | ||
* module doesn't provide equivalent functionality, but it does export a `get` | ||
* function that works similarly to config-chain's `get` (without the where | ||
* argument). | ||
*/ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var cc = require('config-chain'); | ||
function find() { | ||
var rel = path.join.apply(null, [].slice.call(arguments)); | ||
function _find(start, rel) { | ||
var file = path.join(start, rel); | ||
try { | ||
fs.statSync(file); | ||
} catch (err) { | ||
if (path.dirname(start) !== start) { | ||
file = _find(path.dirname(start), rel); | ||
} else { | ||
// at the root | ||
file = undefined; | ||
} | ||
} | ||
return file; | ||
} | ||
return _find(__dirname, rel); | ||
} | ||
function getEnv(prefix, env) { | ||
env = env || process.env; | ||
var obj = {}; | ||
var length = prefix.length; | ||
for (var key in env) { | ||
if (key.indexOf(prefix) === 0) { | ||
obj[key.substring(length)] = env[key]; | ||
} | ||
} | ||
return obj; | ||
} | ||
// assign defaults | ||
var config = require(path.join(__dirname, '..', 'default-config.json')); | ||
// check for project settings | ||
var configPath = find('closure-util.json'); | ||
if (configPath) { | ||
var projectConfig = require(configPath); | ||
for (var key in projectConfig) { | ||
config[key] = projectConfig; | ||
} | ||
} | ||
// check for evn vars | ||
var env = getEnv('closure_'); | ||
for (var key in env) { | ||
config[key] = env[key]; | ||
} | ||
/** | ||
* Configuration object. | ||
* @type {Object} | ||
* Get a config property. | ||
* @param {string} key The property name. | ||
* @return {*} The property value. | ||
*/ | ||
module.exports = cc( | ||
cc.env('closure_'), | ||
cc.find('closure-util.json'), | ||
path.join(__dirname, '..', 'default-config.json')); | ||
exports.get = function(key) { | ||
return config[key]; | ||
}; |
@@ -108,4 +108,4 @@ var crypto = require('crypto'); | ||
var hash = crypto.createHash('sha1'); | ||
hash.update(url); | ||
hash.update(url, 'utf8'); | ||
return path.join(base, hash.digest('hex')); | ||
}; |
{ | ||
"name": "closure-util", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "Utilities for Closure Library based projects.", | ||
@@ -36,3 +36,2 @@ "main": "lib/index.js", | ||
"socket.io": "0.9.16", | ||
"config-chain": "1.1.8", | ||
"fs-extra": "0.8.1", | ||
@@ -39,0 +38,0 @@ "get-down": "0.3.0" |
@@ -63,3 +63,3 @@ # Closure Util | ||
* **options** - `Object` [Options](compiler-options.txt) for the compiler (without the `--` prefix). E.g. the `--output_wrapper` option could be specified with `{output_wrapper: '(function(){%output%})();'}`. For options that can be specified multiple times, provide an array of values (e.g. `{js: ['one.js', 'two.js']}`). For options that are flags (no value), provide a boolean (e.g. `{use_types_for_optimization: true}`). | ||
* **jvm** - `Array.<string>` Optional arguments for the JVM. If this argument is absent (if the function is called with two arguments), `['-server', '-XX:+TieredCompilation']` will be used as JVM arguments. To use [different arguments](https://code.google.com/p/closure-compiler/wiki/FAQ#What_are_the_recommended_Java_VM_command-line_options?), provide an array. | ||
* **jvm** - `Array.<string>` Optional arguments for the JVM. If this argument is absent (if the function is called with two arguments), `['-server', '-XX:+TieredCompilation']` will be used as JVM arguments. To use [different arguments](https://github.com/google/closure-compiler/wiki/FAQ#what-are-the-recommended-java-vm-command-line-options), provide an array. | ||
* **callback** - `function(Error, string)` Called with the compiler output (or any compilation error). | ||
@@ -66,0 +66,0 @@ |
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
84482
13
1926
8
- Removedconfig-chain@1.1.8
- Removedconfig-chain@1.1.8(transitive)
- Removedini@1.3.8(transitive)
- Removedproto-list@1.2.4(transitive)