gravity-js
Advanced tools
+76
-40
@@ -25,3 +25,3 @@ /*global Buffer, global, module, process, require*/ | ||
| gravity.VERSION = '0.7.4'; | ||
| gravity.VERSION = '0.7.5'; | ||
@@ -274,3 +274,3 @@ var | ||
| var | ||
| packer = atom.create(), | ||
| packer = atom(), | ||
| i = -1, | ||
@@ -389,3 +389,3 @@ len = resources.length | ||
| ext = dotparts.pop(), | ||
| request = atom.create(), | ||
| request = atom(), | ||
| logURL = slashpath | ||
@@ -401,4 +401,8 @@ ; | ||
| gravity.map(mapURI, function (result) { | ||
| request.set('map', result); | ||
| gravity.map(mapURI, function (err, result) { | ||
| if (err) { | ||
| throw err; | ||
| } else { | ||
| request.set('map', result); | ||
| } | ||
| }); | ||
@@ -496,3 +500,3 @@ | ||
| function recursiveDirectoryListing(dir, callback) { | ||
| var a = atom.create(), chain = a.chain, list = [], set = a.set; | ||
| var a = atom(), chain = a.chain, list = [], set = a.set; | ||
| chain(function (next) { | ||
@@ -528,3 +532,3 @@ fs.readdir(dir, function (err, files) { | ||
| function getList(base, path, mapNode, callback) { | ||
| var a = atom.create(), chain = a.chain, list = []; | ||
| var a = atom(), chain = a.chain, list = []; | ||
| eachMapProperty(mapNode, function (prop, val, type, isDir) { | ||
@@ -566,3 +570,3 @@ if (prop.charAt(0) === '~') { | ||
| function write(outDir, path, content, callback) { | ||
| var call = atom.create(), outPath = outDir + '/' + path; | ||
| var call = atom(), outPath = outDir + '/' + path; | ||
| gravity.logger('write ' + outPath); | ||
@@ -584,5 +588,5 @@ fs.open(outPath, 'w', function (err, fd) { | ||
| var | ||
| action = atom.create(), | ||
| action = atom(), | ||
| splits = getResourcePathSplits(path), | ||
| dirs = atom.create(), | ||
| dirs = atom(), | ||
| last | ||
@@ -626,36 +630,48 @@ ; | ||
| gravity.build = function (mapOrURI, base, out, callback) { | ||
| var build = atom.create(), files = atom.create(); | ||
| gravity.map(mapOrURI, function (map) { | ||
| build.set('map', map); | ||
| gravity.list(map, base, function (err, list) { | ||
| if (err) { | ||
| build.set('done', err); | ||
| } else { | ||
| build.set('list', list); | ||
| } | ||
| }); | ||
| var | ||
| build = atom(), | ||
| buildSet = build.set, | ||
| files = atom() | ||
| ; | ||
| gravity.map(mapOrURI, function (err, map) { | ||
| if (err) { | ||
| buildSet('done', err); | ||
| } else { | ||
| buildSet('map', map); | ||
| gravity.list(map, base, function (err, list) { | ||
| if (err) { | ||
| buildSet('done', err); | ||
| } else { | ||
| buildSet('list', list); | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
| build.once(['map', 'list'], function (map, list) { | ||
| arrayEach(list, function (i, path) { | ||
| var item = atom.create(); | ||
| var | ||
| item = atom(), | ||
| itemOnce = item.once, | ||
| itemSet = item.set | ||
| ; | ||
| gravity.pull(map, base, path, function (err, content) { | ||
| if (err) { | ||
| build.set('done', err); | ||
| buildSet('done', err); | ||
| } else { | ||
| item.set('content', content); | ||
| itemSet('content', content); | ||
| } | ||
| }); | ||
| item.once('content', function (content) { | ||
| itemOnce('content', function (content) { | ||
| createDirectories(out, path, function (err) { | ||
| if (err) { | ||
| build.set('done', err); | ||
| buildSet('done', err); | ||
| } else { | ||
| item.set('dir', true); | ||
| itemSet('dir', true); | ||
| } | ||
| }); | ||
| }); | ||
| item.once(['content', 'dir'], function (content) { | ||
| itemOnce(['content', 'dir'], function (content) { | ||
| write(out, path, content, function (err) { | ||
| if (err) { | ||
| build.set('done', err); | ||
| buildSet('done', err); | ||
| } else { | ||
@@ -668,3 +684,3 @@ files.set(path, true); | ||
| files.once(list, function () { | ||
| build.set('done', null); | ||
| buildSet('done', null); | ||
| }); | ||
@@ -676,8 +692,12 @@ }); | ||
| gravity.list = function (mapOrURI, base, callback) { | ||
| gravity.map(mapOrURI, function (map) { | ||
| getList(base, '', map, function (list) { | ||
| //gravity.logger('gravity.list(...)', { mapOrURI: mapOrURI, base: base }); | ||
| //gravity.logger(list); | ||
| callback(undefined, list); | ||
| }); | ||
| gravity.map(mapOrURI, function (err, map) { | ||
| if (err) { | ||
| callback(err); | ||
| } else { | ||
| getList(base, '', map, function (list) { | ||
| //gravity.logger('gravity.list(...)', { mapOrURI: mapOrURI, base: base }); | ||
| //gravity.logger(list); | ||
| callback(undefined, list); | ||
| }); | ||
| } | ||
| }); | ||
@@ -688,6 +708,18 @@ }; | ||
| if (typeof mapOrURI === 'string') { | ||
| var gravMapJSON = stripComments(fs.readFileSync(mapOrURI) + ''); | ||
| callback(JSON.parse(gravMapJSON)); | ||
| fs.readFile(mapOrURI, function (err, content) { | ||
| var gravMapJSON, mapData; | ||
| if (err) { | ||
| callback(err); | ||
| } else { | ||
| gravMapJSON = stripComments(content + ''); | ||
| try { | ||
| mapData = JSON.parse(gravMapJSON); | ||
| callback(null, mapData); | ||
| } catch (ex) { | ||
| callback(ex); | ||
| } | ||
| } | ||
| }); | ||
| } else { | ||
| callback(mapOrURI); | ||
| callback(null, mapOrURI); | ||
| } | ||
@@ -698,4 +730,8 @@ }; | ||
| //gravity.logger('gravity.pull(...)', { mapOrURI: mapOrURI, base: base, path: path }); | ||
| gravity.map(mapOrURI, function (map) { | ||
| getResource(map, base, false, path, callback); | ||
| gravity.map(mapOrURI, function (err, map) { | ||
| if (err) { | ||
| callback(err); | ||
| } else { | ||
| getResource(map, base, false, path, callback); | ||
| } | ||
| }); | ||
@@ -702,0 +738,0 @@ }; |
+1
-1
| { | ||
| "name": "gravity-js", | ||
| "version": "0.7.4", | ||
| "version": "0.7.5", | ||
| "description": "A light-weight JS build tool", | ||
@@ -5,0 +5,0 @@ "author": "Chris Campbell <ccampbell@zynga.com> (https://github.com/quaelin)", |
+25
-1
@@ -12,3 +12,3 @@ /*global atom:true, gravity:true, logger:true, process, require*/ | ||
| verbose = inBrowser || arg2 === '-v', | ||
| a = atom.create(), | ||
| a = atom(), | ||
| chain = a.chain, | ||
@@ -45,2 +45,26 @@ results = [], | ||
| chain(function (next) { | ||
| var dir = 'nosuchdir'; | ||
| gravity.build(dir + '/gravity.map', dir, 'nosuchOUTdir', function (err) { | ||
| assert( | ||
| 'gravity.build() returns an error if passed a non-existent ' + | ||
| 'gravity.map file path', | ||
| !!err | ||
| ); | ||
| next(); | ||
| }); | ||
| }); | ||
| chain(function (next) { | ||
| var dir = 'nosuchdir'; | ||
| gravity.list(dir + '/gravity.map', dir, function (err) { | ||
| assert( | ||
| 'gravity.list() returns an error if passed a non-existent ' + | ||
| 'gravity.map file path', | ||
| !!err | ||
| ); | ||
| next(); | ||
| }); | ||
| }); | ||
| chain(function (next) { | ||
| var | ||
@@ -47,0 +71,0 @@ base = 'test/proj-1', |
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
89779
1.1%2624
2.26%