Permalink
Browse files

Abnormal termination when CSS compilation fails.

  • Loading branch information...
1 parent 80c2f3d commit ba880963094792143251b73f252570a817d6b708 @toolness committed Jan 16, 2013
Showing with 20 additions and 21 deletions.
  1. +20 −21 bin/build-require.js
View
@@ -4,21 +4,19 @@ var requirejs = require('requirejs'),
requireConfig = require('../js/require-config'),
rootDir = resolve(__dirname, '..', 'js'),
name = 'friendlycode',
- out = resolve(rootDir, 'friendlycode-built.js');
+ cssIn = resolve(rootDir, "..", "css", "friendlycode.css"),
+ cssOut = resolve(rootDir, "..", "css", "friendlycode-built.css"),
+ jsOut = resolve(rootDir, 'friendlycode-built.js');
-function optimize(done) {
- requirejs.optimize(generateConfig(), done, function(err) {
- process.stderr.write(err.toString());
- process.exit(1);
- });
-}
-
-exports.rootDir = rootDir;
+var bailOnError = function(err) {
+ process.stderr.write(err.toString());
+ process.exit(1);
+};
var generateConfig = exports.generateConfig = function() {
var config = {
name: name,
- out: out,
+ out: jsOut,
// use none optimize for debugging
optimize: "none",
// optimize: 'uglify',
@@ -36,32 +34,33 @@ var generateConfig = exports.generateConfig = function() {
QuerySelector: true
}
});
- },
- // TODO above config setting is temporary, it shuould use mainConfigFile
- // https://github.com/toolness/friendlycode/pull/112#issuecomment-6625412
- // mainConfigFile: "./js/main.js",
+ }
+ // TODO: Consider using mainConfigFile here. For more info, see:
+ // https://github.com/mozilla/friendlycode/pull/112#issuecomment-6625412
};
Object.keys(requireConfig).forEach(function(name) {
config[name] = requireConfig[name];
});
config.baseUrl = rootDir;
return config;
-}
+};
+
+exports.rootDir = rootDir;
if (!module.parent) {
- console.log("Generating", out);
+ console.log("Generating", jsOut);
- optimize(function (buildResponse) {
+ requirejs.optimize(generateConfig(), function (buildResponse) {
// buildResponse is just a text output of the modules
// included.
console.log("Done. About " + buildResponse.split('\n').length +
" modules are inside the generated JS file.");
requirejs.optimize({
- cssIn: "css/friendlycode.css",
- out: "css/friendlycode-built.css"
+ cssIn: cssIn,
+ out: cssOut
}, function() {
console.log("Optimized CSS.");
process.exit();
- });
- });
+ }, bailOnError);
+ }, bailOnError);
}

0 comments on commit ba88096

Please sign in to comment.