Skip to content

Commit

Permalink
Creando registro para #32
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoefe committed Dec 6, 2016
1 parent d18353f commit 437c448
Show file tree
Hide file tree
Showing 4 changed files with 245 additions and 217 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
"start": "node example/server.js",
"all": "npm test && npm run test-cov && qa-control . -v",
"web": "node tools/web.js && git add web",
"web": "node tools/web.js && git add tools && git add web",
"lint": "jshint .",
"validate": "npm ls"
},
Expand Down
4 changes: 4 additions & 0 deletions tools/versions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"iconv-lite": "0.4.13",
"buffer": "4.9.1"
}
34 changes: 29 additions & 5 deletions tools/web.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,35 @@ function bundlePromise(browserifyObject) {

var browserify = require('browserify');

function browserifyOutDated(moduleDir, relativeModuleFileName, exposedName, outputDir) {
var b = browserify();
b.require('./node_modules/'+moduleDir+'/'+relativeModuleFileName, {expose: exposedName});
return bundlePromise(b).then(function(bfbuf) {
return fs.writeFile(outputDir+'/'+exposedName+'.js', bfbuf);
function browserifyOutDated(moduleName, relativeModuleFileName, exposedName, outputDir) {
var moduleDir = './node_modules/'+moduleName+'/';
var registry='./tools/versions.json';
var regJSON, modJSON;
var mustUpdate = false;
return fs.readJson(registry).then(function(json) {
regJSON = json;
return fs.readJson(moduleDir+'package.json');
}).then(function(packageJson) {
modJSON = packageJson;
//console.log("regJSON", regJSON); console.log("packageJson", packageJson.name, packageJson.version);
if(! (modJSON.name in regJSON) || regJSON[modJSON.name] !== modJSON.version) {
mustUpdate = true;
regJSON[modJSON.name] = modJSON.version;
return fs.writeJson(registry, regJSON);
}
}).then(function() {
if(mustUpdate) {
var b = browserify();
b.require(moduleDir+relativeModuleFileName, {expose: exposedName});
return bundlePromise(b);
}
}).then(function(bfbuf) {
if(mustUpdate) {
console.log("Updating to "+modJSON.name+' v.'+modJSON.version)
return fs.writeFile(outputDir+'/'+exposedName+'.js', bfbuf);
} else {
console.log("No update required for "+modJSON.name);
}
});
}

Expand Down
Loading

0 comments on commit 437c448

Please sign in to comment.