+1
-1
@@ -321,3 +321,3 @@ // Generated by CoffeeScript 1.5.0 | ||
| autoStart = (_ref1 = opts.autoStart) != null ? _ref1 : false; | ||
| result = "(function(/*! Stitched by Assembot !*/) {\n if (!this." + identifier + ") {\n var modules = {}, cache = {}, require = function(name, root) {\n var path = expand(root, name), module = cache[path], fn;\n if (module) {\n return module.exports;\n } else if (fn = modules[path] || modules[path = expand(path, './index')]) {\n module = {id: path, exports: {}};\n try {\n cache[path] = module;\n fn(module.exports, function(name) {\n return require(name, dirname(path));\n }, module);\n return module.exports;\n } catch (err) {\n delete cache[path];\n throw err;\n }\n } else {\n throw 'module \\'' + name + '\\' not found';\n }\n }, expand = function(root, name) {\n var results = [], parts, part;\n if (/^\\.\\.?(\\/|$)/.test(name)) {\n parts = [root, name].join('/').split('/');\n } else {\n parts = name.split('/');\n }\n for (var i = 0, length = parts.length; i < length; i++) {\n part = parts[i];\n if (part == '..') {\n results.pop();\n } else if (part != '.' && part != '') {\n results.push(part);\n }\n }\n return results.join('/');\n }, dirname = function(path) {\n return path.split('/').slice(0, -1).join('/');\n };\n this." + identifier + " = function(name) {\n return require(name, '');\n }\n this." + identifier + ".define = function(bundle) {\n for (var key in bundle)\n modules[key] = bundle[key];\n };\n this." + identifier + ".modules= function() {\n var names= [];\n for( var name in modules)\n names.push(name);\n return names;\n }\n }\n return this." + identifier + ".define;\n}).call(this)({\n"; | ||
| result = "(function(/*! Stitched by Assembot !*/) {\n if (!this." + identifier + ") {\n var modules = {}, cache = {}, moduleList= function() {\n var names= [];\n for( var name in modules ) {\n names.push(name);\n }\n return names;\n }, require = function(name, root) {\n var path = expand(root, name), module = cache[path], fn;\n if (module) {\n return module.exports;\n } else if (fn = modules[path] || modules[path = expand(path, './index')]) {\n module = {id: path, exports: {}};\n try {\n cache[path] = module;\n var localRequire= function(name) {\n return require(name, dirname(path));\n }\n localRequire.modules= moduleList;\n fn(module.exports, localRequire, module);\n return module.exports;\n } catch (err) {\n delete cache[path];\n throw err;\n }\n } else {\n throw 'module \\'' + name + '\\' not found';\n }\n }, expand = function(root, name) {\n var results = [], parts, part;\n if (/^\\.\\.?(\\/|$)/.test(name)) {\n parts = [root, name].join('/').split('/');\n } else {\n parts = name.split('/');\n }\n for (var i = 0, length = parts.length; i < length; i++) {\n part = parts[i];\n if (part == '..') {\n results.pop();\n } else if (part != '.' && part != '') {\n results.push(part);\n }\n }\n return results.join('/');\n }, dirname = function(path) {\n return path.split('/').slice(0, -1).join('/');\n };\n this." + identifier + " = function(name) {\n return require(name, '');\n }\n this." + identifier + ".define = function(bundle) {\n for (var key in bundle)\n modules[key] = bundle[key];\n };\n this." + identifier + ".modules= moduleList;\n }\n return this." + identifier + ".define;\n}).call(this)({\n"; | ||
| index = 0; | ||
@@ -324,0 +324,0 @@ for (name in sources) { |
+45
-23
@@ -27,3 +27,3 @@ // Generated by CoffeeScript 1.5.0 | ||
| run: function() { | ||
| var assbot_conf, assembot_info, buildTo, command, config, empty, nfo, options, parser, project_root; | ||
| var assbot_conf, assembot_info, buildTo, command, config, empty, nfo, options, parser, project_root, template; | ||
| command = 'help'; | ||
@@ -36,5 +36,17 @@ buildTo = { | ||
| project_root = process.cwd(); | ||
| options = _.extend({}, defaults.options); | ||
| assembot_info = require('../package'); | ||
| parser = new optparse.OptionParser([['-b', '--build', 'Run build'], ['-s', '--serve', 'Run dev server'], ['-f', '--files', 'Shows the build targets and associated files'], ['-d', '--debug', 'Shows internal build config data'], ['-p', '--port [PORT]', "Set dev server port"], ['-r', '--root [PATH]', 'Set dev server root path'], ['-m', '--minify [LEVEL]', 'Force minification 0=none 1=minify 2=mangle'], ['-c', '--modules', 'Shows the commonjs modules for .js build targets'], ['-c', '--modules', 'Shows the commonjs modules for .js build targets'], ['-v', '--version', 'Shows version number'], ['-h', '--help', 'Shows help'], ['--source [PATH]', 'Set source folder'], ['--js [PATH]', 'Export js package from source'], ['--css [PATH]', 'Export jcss package from source']]); | ||
| nfo = (function() { | ||
| try { | ||
| return require("" + project_root + path.sep + "package"); | ||
| } catch (ex) { | ||
| _.puts("No 'package.json' file found, using defaults!"); | ||
| return empty = { | ||
| assembot: _.extend({}, defaults.assembot) | ||
| }; | ||
| } | ||
| })(); | ||
| assbot_conf = nfo.assembot == null ? (_.puts("No 'assembot' block in your package.json file found, using defaults!"), _.extend({}, defaults.assembot)) : nfo.assembot; | ||
| options = _.defaults({}, assbot_conf.options || {}, defaults.options); | ||
| delete assbot_conf.options; | ||
| parser = new optparse.OptionParser([['-b', '--build', 'Run build'], ['-s', '--serve', 'Run dev server'], ['-f', '--files', 'Shows the build targets and associated files'], ['-d', '--debug', 'Shows internal build config data'], ['-p', '--port [PORT]', "Set dev server port"], ['-r', '--root [PATH]', 'Set dev server root path'], ['-m', '--minify [LEVEL]', 'Force minification 0=none 1=minify 2=mangle'], ['-c', '--modules', 'Shows the commonjs modules for .js build targets'], ['-v', '--version', 'Shows version number'], ['-h', '--help', 'Shows help'], ['--init', 'Creates a package.json, if missing'], ['--source [PATH]', 'Set source folder'], ['--js [PATH]', 'Export js package from source'], ['--css [PATH]', 'Export css package from source']]); | ||
| parser.banner = 'Usage: assembot [options]'; | ||
@@ -53,2 +65,5 @@ parser.on('build', function(name, value) { | ||
| }); | ||
| parser.on('init', function(name, value) { | ||
| return command = name; | ||
| }); | ||
| parser.on('minify', function(name, value) { | ||
@@ -69,2 +84,11 @@ return options.minify = parseInt(value || "1"); | ||
| }); | ||
| parser.on('js', function(name, value) { | ||
| return buildTo[name] = value; | ||
| }); | ||
| parser.on('css', function(name, value) { | ||
| return buildTo[name] = value; | ||
| }); | ||
| parser.on('*', function(name, value) { | ||
| return _.puts("Unknown option: " + name); | ||
| }); | ||
| parser.on('root', function(name, value) { | ||
@@ -83,23 +107,3 @@ var newRoot; | ||
| }); | ||
| parser.on('js', function(name, value) { | ||
| return buildTo[name] = value; | ||
| }); | ||
| parser.on('css', function(name, value) { | ||
| return buildTo[name] = value; | ||
| }); | ||
| parser.on('*', function(name, value) { | ||
| return _.puts("Unknown option: " + name); | ||
| }); | ||
| parser.parse(process.argv); | ||
| nfo = (function() { | ||
| try { | ||
| return require("" + project_root + path.sep + "package"); | ||
| } catch (ex) { | ||
| console.log("No 'package.json' file found, using defaults!"); | ||
| return empty = { | ||
| assembot: _.extend({}, defaults.assembot) | ||
| }; | ||
| } | ||
| })(); | ||
| assbot_conf = nfo.assembot == null ? (console.log("No 'assembot' block in your package.json file found, using defaults!"), _.extend({}, defaults.assembot)) : nfo.assembot; | ||
| if (command === 'serve') { | ||
@@ -118,2 +122,20 @@ return server.serve(assbot_conf, options); | ||
| return _.puts(assembot_info.version); | ||
| } else if (command === 'init') { | ||
| _.puts("ASSEMBOT! Bleep, bloop!\nv" + assembot_info.version + "\n"); | ||
| if (fs.existsSync('./package.json')) { | ||
| return _.puts("package.json already exists."); | ||
| } else { | ||
| _.puts("Creating a default package.json for you..."); | ||
| assembot_conf.options = defaults.options; | ||
| template = { | ||
| name: path.basename(process.cwd()), | ||
| version: "1.0.0", | ||
| license: "", | ||
| description: "", | ||
| author: "", | ||
| assembot: assbot_conf | ||
| }; | ||
| fs.writeFileSync(path.resolve('./package.json'), JSON.stringify(template, null, 2)); | ||
| return _.puts('Done.'); | ||
| } | ||
| } else if (command === 'source') { | ||
@@ -120,0 +142,0 @@ config = {}; |
+53
-10
| // Generated by CoffeeScript 1.5.0 | ||
| (function() { | ||
| var addConvertor, addCssConvertor, addJsConvertor, api, assembot_package, fs, path, project_package, project_root, type_db, validType, _; | ||
| var addConvertor, addConvertorOLD, addCssConvertor, addJsConvertor, api, assembot_package, fs, path, project_package, project_root, type_db, validType, _; | ||
@@ -106,3 +106,3 @@ path = require('path'); | ||
| addConvertor = function(target, type, modules, handler) { | ||
| addConvertorOLD = function(target, type, modules, handler) { | ||
| var args, converter; | ||
@@ -159,2 +159,40 @@ if (!_.isArray(modules)) { | ||
| addConvertor = function(target, type, modules, handler) { | ||
| var loading, queue; | ||
| if (!_.isArray(modules)) { | ||
| modules = [modules]; | ||
| } | ||
| loading = false; | ||
| queue = []; | ||
| return api.addFor(target, type, function(origSrc, origOpts, origCallback) { | ||
| queue.push([origSrc, origOpts, origCallback]); | ||
| if (!loading) { | ||
| loading = true; | ||
| return _.tryRequireAll(modules, function(err, libs) { | ||
| var arglist, converter, safeHandler, _i, _len, _results; | ||
| if (err != null) { | ||
| throw "Module(s) '" + (modules.join("'")) + "' cannot be loaded! " + err; | ||
| } | ||
| converter = handler.apply(handler, libs); | ||
| safeHandler = function(src, opts, callback) { | ||
| var file; | ||
| try { | ||
| return converter(src, opts, callback); | ||
| } catch (ex) { | ||
| file = "" + opts.current_file.path + opts.current_file.ext; | ||
| return c(new Error("Transpiler error for " + file + ": " + ex.message), null, opts); | ||
| } | ||
| }; | ||
| api.addFor(target, type, safeHandler); | ||
| _results = []; | ||
| for (_i = 0, _len = queue.length; _i < _len; _i++) { | ||
| arglist = queue[_i]; | ||
| _results.push(safeHandler.apply(safeHandler, arglist)); | ||
| } | ||
| return _results; | ||
| }); | ||
| } | ||
| }); | ||
| }; | ||
| addJsConvertor = function(type, modules, handler) { | ||
@@ -200,3 +238,3 @@ var thisType, _i, _len; | ||
| var options, output; | ||
| options = _.defaults(opts.coffee || {}, { | ||
| options = _.defaults({}, opts.coffee || {}, { | ||
| bare: true | ||
@@ -232,3 +270,3 @@ }); | ||
| var options, output; | ||
| options = _.defaults(opts.handlebars || {}, { | ||
| options = _.defaults({}, opts.handlebars || {}, { | ||
| simple: false, | ||
@@ -245,3 +283,3 @@ commonjs: true | ||
| var options, output; | ||
| options = _.defaults(opts.jade || {}, { | ||
| options = _.defaults({}, opts.jade || {}, { | ||
| client: true, | ||
@@ -258,3 +296,3 @@ compileDebug: false | ||
| var options, output; | ||
| options = _.defaults(opts.hogan || {}, { | ||
| options = _.defaults({}, opts.hogan || {}, { | ||
| asString: 1 | ||
@@ -270,3 +308,3 @@ }); | ||
| var options, output; | ||
| options = _.defaults(opts.dot || opts.doT || {}, {}); | ||
| options = _.defaults({}, opts.dot || opts.doT || {}, {}); | ||
| output = dot.compile(source, options); | ||
@@ -280,3 +318,3 @@ return converted(null, "module.exports= " + (output.toString()), opts); | ||
| var options, output; | ||
| options = _.defaults(opts.dot || opts.doT || {}, { | ||
| options = _.defaults({}, opts.marked || {}, { | ||
| gfm: true, | ||
@@ -290,3 +328,3 @@ tables: true, | ||
| output = marked(source, options); | ||
| return converted(null, "module.exports= " + (JSON.stringify(output)), opts); | ||
| return converted(null, "module.exports=" + (JSON.stringify(output)) + ";", opts); | ||
| }; | ||
@@ -316,3 +354,8 @@ }); | ||
| return function(source, opts, converted) { | ||
| return stylus(source).set('filename', opts.current_file.filename || 'generated.css').set('paths', load_paths).use(nib()).render(function(err, css) { | ||
| var options; | ||
| options = _.defaults({}, opts.marked || {}, { | ||
| filename: opts.current_file.filename || 'generated.css', | ||
| paths: load_paths | ||
| }); | ||
| return stylus(source).set('filename', opts.current_file.filename || 'generated.css').set('paths', load_paths).set(options).use(nib()).render(function(err, css) { | ||
| if (err != null) { | ||
@@ -319,0 +362,0 @@ return converted(err, null, opts); |
+25
-0
@@ -92,2 +92,27 @@ // Generated by CoffeeScript 1.5.0 | ||
| exports.tryRequireAll = function(names, callback) { | ||
| var libnames, libs, loader, nextLib; | ||
| if (names.length === 0) { | ||
| callback(null, []); | ||
| return; | ||
| } | ||
| libs = []; | ||
| libnames = names.slice(); | ||
| nextLib = libnames.shift(); | ||
| loader = function(err, lib) { | ||
| if (err != null) { | ||
| return callback(err, null); | ||
| } else { | ||
| libs.push(lib); | ||
| if (libnames.length === 0) { | ||
| return callback(null, libs); | ||
| } else { | ||
| nextLib = libnames.shift(); | ||
| return exports.tryRequire(nextLib, loader); | ||
| } | ||
| } | ||
| }; | ||
| return exports.tryRequire(nextLib, loader); | ||
| }; | ||
| _ = exports; | ||
@@ -94,0 +119,0 @@ |
+4
-0
@@ -12,3 +12,7 @@ | ||
| pushtags: | ||
| git push dropbox --tag | ||
| git push github --tag | ||
| publish: | ||
| npm publish |
+1
-1
| { | ||
| "name": "assembot", | ||
| "version": "0.1.4", | ||
| "version": "0.1.6", | ||
| "license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Simple asset assembly bot for compiling/combining client-side js and css files.", |
+12
-9
@@ -206,3 +206,9 @@ path= require 'path' | ||
| if (!this.#{identifier}) { | ||
| var modules = {}, cache = {}, require = function(name, root) { | ||
| var modules = {}, cache = {}, moduleList= function() { | ||
| var names= []; | ||
| for( var name in modules ) { | ||
| names.push(name); | ||
| } | ||
| return names; | ||
| }, require = function(name, root) { | ||
| var path = expand(root, name), module = cache[path], fn; | ||
@@ -215,5 +221,7 @@ if (module) { | ||
| cache[path] = module; | ||
| fn(module.exports, function(name) { | ||
| var localRequire= function(name) { | ||
| return require(name, dirname(path)); | ||
| }, module); | ||
| } | ||
| localRequire.modules= moduleList; | ||
| fn(module.exports, localRequire, module); | ||
| return module.exports; | ||
@@ -253,8 +261,3 @@ } catch (err) { | ||
| }; | ||
| this.#{identifier}.modules= function() { | ||
| var names= []; | ||
| for( var name in modules) | ||
| names.push(name); | ||
| return names; | ||
| } | ||
| this.#{identifier}.modules= moduleList; | ||
| } | ||
@@ -261,0 +264,0 @@ return this.#{identifier}.define; |
+42
-19
@@ -22,4 +22,16 @@ ### | ||
| project_root= process.cwd() | ||
| options= _.extend {}, defaults.options | ||
| assembot_info= require '../package' | ||
| nfo= try | ||
| require "#{project_root}#{path.sep}package" | ||
| catch ex | ||
| _.puts "No 'package.json' file found, using defaults!" | ||
| empty= | ||
| assembot: _.extend {}, defaults.assembot | ||
| assbot_conf= unless nfo.assembot? | ||
| _.puts "No 'assembot' block in your package.json file found, using defaults!" | ||
| _.extend {}, defaults.assembot | ||
| else | ||
| nfo.assembot | ||
| options= _.defaults {}, (assbot_conf.options || {}), defaults.options | ||
| delete assbot_conf.options | ||
@@ -35,8 +47,8 @@ parser = new optparse.OptionParser [ | ||
| ['-c', '--modules', 'Shows the commonjs modules for .js build targets'] | ||
| ['-c', '--modules', 'Shows the commonjs modules for .js build targets'] | ||
| ['-v', '--version', 'Shows version number'] | ||
| ['-h', '--help', 'Shows help'] | ||
| [ '--init', 'Creates a package.json, if missing'] | ||
| [ '--source [PATH]', 'Set source folder'] | ||
| [ '--js [PATH]', 'Export js package from source'] | ||
| [ '--css [PATH]', 'Export jcss package from source'] | ||
| [ '--css [PATH]', 'Export css package from source'] | ||
| # [ '--out', 'Build to STDOUT'] | ||
@@ -51,2 +63,3 @@ ] | ||
| parser.on 'files', (name, value)-> command= name | ||
| parser.on 'init', (name, value)-> command= name | ||
| parser.on 'minify', (name, value)-> options.minify= parseInt value || "1" | ||
@@ -57,2 +70,5 @@ parser.on 'modules', (name, value)-> command= name | ||
| parser.on 'version', (name, value)-> command= name | ||
| parser.on 'js', (name, value)-> buildTo[name]= value | ||
| parser.on 'css', (name, value)-> buildTo[name]= value | ||
| parser.on '*', (name, value)-> _.puts "Unknown option: #{name}" | ||
| parser.on 'root', (name, value)-> | ||
@@ -67,21 +83,5 @@ newRoot= path.resolve(value) | ||
| buildTo.source= value | ||
| parser.on 'js', (name, value)-> buildTo[name]= value | ||
| parser.on 'css', (name, value)-> buildTo[name]= value | ||
| parser.on '*', (name, value)-> _.puts "Unknown option: #{name}" | ||
| parser.parse process.argv | ||
| nfo= try | ||
| require "#{project_root}#{path.sep}package" | ||
| catch ex | ||
| console.log "No 'package.json' file found, using defaults!" | ||
| empty= | ||
| assembot: _.extend {}, defaults.assembot | ||
| assbot_conf= unless nfo.assembot? | ||
| console.log "No 'assembot' block in your package.json file found, using defaults!" | ||
| _.extend {}, defaults.assembot | ||
| else | ||
| nfo.assembot | ||
| if command is 'serve' | ||
@@ -106,2 +106,25 @@ server.serve assbot_conf, options | ||
| else if command is 'init' | ||
| _.puts """ | ||
| ASSEMBOT! Bleep, bloop! | ||
| v#{ assembot_info.version } | ||
| """ | ||
| if fs.existsSync './package.json' | ||
| _.puts "package.json already exists." | ||
| else | ||
| _.puts "Creating a default package.json for you..." | ||
| assembot_conf.options= defaults.options | ||
| template= | ||
| name: path.basename(process.cwd()) | ||
| version: "1.0.0" | ||
| license: "" | ||
| description: "" | ||
| author: "" | ||
| assembot: assbot_conf | ||
| # _.puts JSON.stringify(template, null, 2) | ||
| fs.writeFileSync path.resolve('./package.json'), JSON.stringify(template, null, 2) | ||
| _.puts 'Done.' | ||
| else if command is 'source' | ||
@@ -108,0 +131,0 @@ config={} |
+34
-12
@@ -81,3 +81,3 @@ path= require 'path' | ||
| addConvertor= (target, type, modules, handler)-> | ||
| addConvertorOLD= (target, type, modules, handler)-> | ||
| modules= [modules] unless _.isArray modules | ||
@@ -116,8 +116,27 @@ args= [] | ||
| addConvertor= (target, type, modules, handler)-> | ||
| modules= [modules] unless _.isArray modules | ||
| loading= no | ||
| queue= [] | ||
| api.addFor target, type, (origSrc, origOpts, origCallback)-> | ||
| queue.push [origSrc, origOpts, origCallback] | ||
| unless loading | ||
| loading= yes | ||
| _.tryRequireAll modules, (err, libs)-> | ||
| if err? | ||
| throw "Module(s) '#{ modules.join "'"}' cannot be loaded! #{err}" | ||
| converter= handler.apply handler, libs | ||
| safeHandler= (src,opts,callback)-> | ||
| try | ||
| converter(src,opts,callback) | ||
| catch ex | ||
| file= "#{ opts.current_file.path }#{ opts.current_file.ext }" | ||
| c new Error("Transpiler error for #{ file }: #{ ex.message }"), null, opts | ||
| api.addFor target, type, safeHandler | ||
| for arglist in queue | ||
| safeHandler.apply safeHandler, arglist | ||
| addJsConvertor= (type, modules, handler)-> | ||
| if _.isArray type | ||
| # _.pp type | ||
| for thisType in type | ||
| # _.puts "SPLITTING OUT" | ||
| # _.pp thisType | ||
| addConvertor 'js', thisType, modules, handler | ||
@@ -148,6 +167,5 @@ else | ||
| (source, opts, converted)-> | ||
| options = _.defaults (opts.coffee || {}), | ||
| options = _.defaults {}, (opts.coffee || {}), | ||
| bare: yes | ||
| options.literate= (opts.current_file.ext is '.litcoffee' || no) | ||
| # _.pp options | ||
| output= coffee.compile source, options | ||
@@ -168,3 +186,3 @@ converted null, output, opts | ||
| (source, opts, converted)-> | ||
| options= _.defaults (opts.handlebars || {}), | ||
| options= _.defaults {}, (opts.handlebars || {}), | ||
| simple: false | ||
@@ -177,3 +195,3 @@ commonjs: true | ||
| (source, opts, converted)-> | ||
| options= _.defaults (opts.jade || {}), | ||
| options= _.defaults {}, (opts.jade || {}), | ||
| client: true | ||
@@ -186,3 +204,3 @@ compileDebug: false | ||
| (source, opts, converted)-> | ||
| options= _.defaults (opts.hogan || {}), | ||
| options= _.defaults {}, (opts.hogan || {}), | ||
| asString: 1 | ||
@@ -194,3 +212,3 @@ output= hogan.compile(source, options) | ||
| (source, opts, converted)-> | ||
| options= _.defaults (opts.dot || opts.doT || {}), {} | ||
| options= _.defaults {}, (opts.dot || opts.doT || {}), {} | ||
| output= dot.compile(source, options) | ||
@@ -202,3 +220,3 @@ # _.pp """module.exports= #{ output.toString() }""" | ||
| (source, opts, converted)-> | ||
| options= _.defaults (opts.dot || opts.doT || {}), | ||
| options= _.defaults {}, (opts.marked || {}), | ||
| gfm: true | ||
@@ -212,3 +230,3 @@ tables: true | ||
| # _.pp """module.exports= #{ output.toString() }""" | ||
| converted null, """module.exports= #{ JSON.stringify output }""", opts | ||
| converted null, """module.exports=#{ JSON.stringify output };""", opts | ||
@@ -231,5 +249,9 @@ # TODO: Add default converters for: yaml(?), others? | ||
| (source, opts, converted)-> | ||
| options= _.defaults {}, (opts.marked || {}), | ||
| filename: opts.current_file.filename || 'generated.css' | ||
| paths: load_paths | ||
| stylus(source) | ||
| .set('filename', opts.current_file.filename || 'generated.css') | ||
| .set('paths', load_paths) | ||
| .set(options) | ||
| .use(nib()) | ||
@@ -236,0 +258,0 @@ .render (err, css)-> |
+22
-33
@@ -30,13 +30,11 @@ util= require 'util' | ||
| if stat.isDirectory() | ||
| # Dive into the directory | ||
| # Keep on walkin... | ||
| callback filename, fullpath, true unless files_only | ||
| walk fullpath, callback | ||
| else | ||
| # Call the callback | ||
| # Call back... | ||
| callback filename, fullpath, false | ||
| file_list | ||
| # This may only be needed when using Assembot with npm link, I'm not sure. | ||
| exports.tryRequire= (name, callback)-> | ||
| # _.log "tryRequire('#{ name }')" | ||
| if name is null or name is '' | ||
@@ -54,14 +52,23 @@ callback null, {} | ||
| localRequire name, callback | ||
| # exports.tryRequireLocalFirst= (name, callback)-> | ||
| # localRequire name, (err, lib)-> | ||
| # if err? | ||
| # try | ||
| # lib= require name | ||
| # callback null, lib | ||
| # catch ex | ||
| # callback ex, null | ||
| # else | ||
| # callback null, lib | ||
| exports.tryRequireAll= (names, callback)-> | ||
| if names.length is 0 | ||
| callback(null, []) | ||
| return | ||
| libs=[] | ||
| libnames= names.slice() | ||
| nextLib= libnames.shift() | ||
| loader= (err, lib)-> | ||
| if err? | ||
| callback err, null | ||
| else | ||
| libs.push lib | ||
| if libnames.length is 0 | ||
| callback null, libs | ||
| else | ||
| nextLib= libnames.shift() | ||
| exports.tryRequire nextLib, loader | ||
| exports.tryRequire nextLib, loader | ||
| _= exports | ||
@@ -74,8 +81,5 @@ | ||
| if loaded_libs[name]? | ||
| # _.puts "RMOTE LIB CACHE FOR: #{name}" | ||
| callback(null, loaded_libs[name]) | ||
| return | ||
| # _.puts "Local require #{name}" | ||
| if loading_now[name]? | ||
| # _.puts "Adding to load queue (#{name})" | ||
| loading_now[name].push callback | ||
@@ -87,10 +91,4 @@ return | ||
| # _.puts "LOADING REMOTE LIB (#{name})" | ||
| cmd= "#{process.execPath} -p -e \"require.resolve('#{ name }')\"" | ||
| # _.log cmd | ||
| child= exec cmd, (stdin, stdout, stderr)-> | ||
| # if stderr isnt '' | ||
| # _.log "STDERR OUTPUT!" | ||
| # _.pp stderr | ||
| libpath= stdout.trim() | ||
@@ -100,25 +98,16 @@ if libpath is '' | ||
| for cb in loading_now[name] | ||
| # _.log " >> error callback (#{name})" | ||
| cb err, null | ||
| delete loading_now[name] | ||
| # callback(new Error("Could not load '#{name}' module. (no local path)"), null) | ||
| try | ||
| # _.log "Loading: #{libpath}" | ||
| lib= require libpath | ||
| loaded_libs[name]= lib | ||
| for cb in loading_now[name] | ||
| # _.log " >> callback (#{name})" | ||
| # _.pp cb.toString() | ||
| cb null, lib | ||
| delete loading_now[name] | ||
| catch ex | ||
| # _.log "Exception!" | ||
| for cb in loading_now[name] | ||
| # _.log " >> error callback (#{name})" | ||
| cb ex, null | ||
| delete loading_now[name] | ||
| # callback ex, null | ||
| true | ||
| exports.extend exports, util |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
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
66986
7.3%1060
9.05%