Add new cjs conversion method

pull/268/head
Jonathan Frederic 11 years ago
parent c8ff593efc
commit 4c07a8bffc

@ -1,33 +1,66 @@
var fs = require('fs');
var aliasify = require('aliasify');
var browserify = require('browserify');
if (process.argv.length >= 4) {
var fs = require('fs');
var aliasify = require('aliasify');
var browserify = require('browserify');
var aliasifyConfig = {
aliases: {
// underscore : 'components/underscore/underscore-min',
// backbone : 'components/backbone/backbone-min',
// jquery: 'components/jquery/jquery.min',
bootstrap: 'components/bootstrap/js/bootstrap.min',
bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min',
// jqueryui: 'components/jquery-ui/ui/minified/jquery-ui.min',
// moment: 'components/moment/moment',
// codemirror: 'components/codemirror',
// termjs: 'components/term.js/src/term'
jqueryui: 'jquery-ui',
termjs: 'term.js'
},
verbose: false
}
var aliasifyConfig = {
aliases: {
// underscore : 'components/underscore/underscore-min',
// backbone : 'components/backbone/backbone-min',
// jquery: 'components/jquery/jquery.min',
bootstrap: 'components/bootstrap/js/bootstrap.min',
bootstraptour: 'components/bootstrap-tour/build/js/bootstrap-tour.min',
// jqueryui: 'components/jquery-ui/ui/minified/jquery-ui.min',
// moment: 'components/moment/moment',
// codemirror: 'components/codemirror',
// termjs: 'components/term.js/src/term'
jqueryui: 'jquery-ui',
termjs: 'term.js'
},
verbose: false
}
var b = browserify({
paths: [
__dirname + '/static',
],
debug: true,
fullPaths: true
});
var b = browserify({
paths: [
__dirname + '/static',
],
debug: true,
fullPaths: true
});
b.transform(aliasify, aliasifyConfig);
b.add(__dirname + '/static/' + process.argv[2]);
b.bundle().pipe(fs.createWriteStream(__dirname + '/static/' + process.argv[3]));
b.transform(aliasify, aliasifyConfig);
b.add(__dirname + '/static/' + process.argv[2]);
b.bundle().pipe(fs.createWriteStream(__dirname + '/static/' + process.argv[3]));
} else {
var amdWrap = require("amd-wrap-legacy");
var glob = require("glob");
var path = require('path');
var fs = require('fs');
var source = "./notebook/static-src";
var destination = "./notebook/static";
glob(path.join(source, "**/*.js"), function(err, files) {
if (err) {
console.error('Could not glob files.', err);
} else {
files.forEach(function(file, index) {
var toFile = path.join(destination, path.relative(source, file));
fs.readFile(file, 'utf8', function (err, data) {
if (err) {
console.error('Could not read file ' + file, err);
} else {
fs.writeFile(toFile, amdWrap(data), function(err) {
if(err) {
return console.error('Could not write file ' + toFile, err);
}
});
}
});
});
}
});
// var wrapped = amdWrap("module.exports = 5;");
}

@ -19,7 +19,7 @@
"build:css:ipython": "lessc --source-map --include-path=./notebook/static/ ./notebook/static/style/ipython.less ./notebook/static/style/ipython.min.css",
"build:css:style": "lessc --source-map --include-path=./notebook/static/ ./notebook/static/style/style.less ./notebook/static/style/style.min.css",
"build:js": "concurrent \"npm run build:js:amd\" \"npm run build:js:tree\" \"npm run build:js:terminal\" \"npm run build:js:notebook\" \"npm run build:js:edit\" \"npm run build:js:auth\" \"npm run build:js:contents\"",
"build:amd": "r.js -convert ./notebook/static-src ./notebook/static",
"build:amd": "node ./notebook/build.js",
"build:js:notebook": "node ./notebook/build.js notebook/js/main.js notebook/js/main.bundle.js",
"build:js:contents": "node ./notebook/build.js services/contents.js services/contents.bundle.js",
"build:js:edit": "node ./notebook/build.js edit/js/main.js edit/js/main.bundle.js",
@ -29,6 +29,7 @@
},
"devDependencies": {
"aliasify": "^1.7.2",
"amd-wrap-legacy": "^0.2.0",
"backbone": "~1.2",
"bower": "*",
"browserify": "^11.0.1",
@ -39,7 +40,6 @@
"less": "~2",
"marked": "~0.3",
"moment": "~2.8.4",
"requirejs": "^2.1.20",
"rimraf": "^2.4.2",
"term.js": "~0.0.4",
"text-encoding": "~0.1",

Loading…
Cancel
Save