collect-require
Advanced tools
Comparing version 1.2.0 to 1.3.0
{ | ||
"name": "collect-require", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "collect require-js based codebase into a singel js file ", | ||
"main": "src/collect-require.js", | ||
"scripts": { | ||
"test": "test" | ||
"test": "mocha test/e2e/module-test.js" | ||
}, | ||
@@ -9,0 +9,0 @@ "repository": { |
@@ -6,2 +6,3 @@ require("./require-template"); | ||
apiNamePlaceHolder = "SCRIPT_COLLECTOR_API_NAME", | ||
globalHookPlaceHolder = "GLOBAL_HOOK", | ||
scriptMappingsPlaceholder = "/*!<SCRIPT-MAPPINGS>!*/"; | ||
@@ -20,8 +21,14 @@ | ||
save: function(options){ | ||
return fs.writeFileSync( | ||
options.path, | ||
wrapperScript.replace(scriptMappingsPlaceholder, scriptMapping) | ||
.replace("/*!<SCRIPT-MAIN>!*/" , options.main.replace(".js", "")) | ||
.replace(apiNamePlaceHolder , options.apiName) | ||
); | ||
var script = wrapperScript.replace(scriptMappingsPlaceholder, scriptMapping) | ||
.replace("/*!<SCRIPT-MAIN>!*/", options.main.replace(".js", "")) | ||
.replace(apiNamePlaceHolder, options.apiName); | ||
if(options.buildNashorn){ | ||
fs.writeFileSync(options.buildNashorn, script.replace(globalHookPlaceHolder, "GLOBAL")); | ||
} | ||
if(options.buildBrowser){ | ||
fs.writeFileSync(options.buildBrowser, script.replace(globalHookPlaceHolder, "window")); | ||
} | ||
} | ||
@@ -28,0 +35,0 @@ }; |
@@ -22,3 +22,3 @@ var | ||
}; | ||
var global = GLOBAL || Window | ||
global.SCRIPT_COLLECTOR_API_NAME = standalone[main](); | ||
GLOBAL_HOOK.SCRIPT_COLLECTOR_API_NAME = standalone[main](); |
@@ -26,4 +26,17 @@ var expect = require('chai').expect, | ||
standalone.save({ | ||
path : path, | ||
main : "three/three.five/script-three.five" , | ||
buildNashorn : path, | ||
main : "three/three.five/script-three.five" , | ||
apiName : "Jeyson", | ||
}); | ||
helper.evalScript(path); | ||
}); | ||
it('should create standalone Nashorn script', function () { | ||
var path = helper.aWritableFilePath(), | ||
standalone = collector.collect(helper.codebasePath); | ||
standalone.save({ | ||
buildNashorn : path, | ||
main : "index.js" , | ||
apiName : "Jeyson", | ||
@@ -33,5 +46,7 @@ }); | ||
helper.evalScript(path); | ||
expect(Jeyson.get()).to.equal("from script three"); | ||
}); | ||
it('should create standalone script file', function () { | ||
it('should create standalone Browser script', function () { | ||
var path = helper.aWritableFilePath(), | ||
@@ -41,3 +56,3 @@ standalone = collector.collect(helper.codebasePath); | ||
standalone.save({ | ||
path : path, | ||
buildBrowser : path, | ||
main : "index.js" , | ||
@@ -47,2 +62,4 @@ apiName : "Jeyson", | ||
GLOBAL.window = GLOBAL; | ||
helper.evalScript(path); | ||
@@ -59,3 +76,3 @@ | ||
standalone.save({ | ||
path : path, | ||
buildNashorn : path, | ||
main : "two/script-two.js", | ||
@@ -62,0 +79,0 @@ apiName : "ScriptTwo", |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
8495
16
146
1
26