Permalink
Browse files

Refactor build scripts

Pass jshint
Remove ; after 'use strict' in commonjs-stripper
  • Loading branch information...
1 parent 48f8eac commit 49f24b1e6be042d4b2d30ae91fe47f750488c033 @curvedmark committed Mar 22, 2013
Showing with 44 additions and 45 deletions.
  1. +1 −1 Makefile
  2. +10 −13 build/commonjs-stripper
  3. +18 −17 build/json
  4. +13 −13 build/mustache
  5. +2 −1 dist/roole.js.mustache
View
@@ -173,7 +173,7 @@ node_modules/%:
JS_FILES = $(shell find lib -type f \( -name '*.js' ! -name 'generatedParser.js' \))
lint: node_modules/.bin/jshint
- @$< bin/roole test/assert.js $(JS_FILES)
+ @$< bin/roole test/assert.js build/* $(JS_FILES)
publish: lib/parser/generatedParser.js
npm publish
@@ -1,18 +1,15 @@
#!/usr/bin/env node
-'use strict'
+'use strict';
-var fs = require('fs')
-var inputPaths = process.argv.slice(2)
-inputPaths.forEach(function(inputPath, i) {
+var fs = require('fs');
+var inputPaths = process.argv.slice(2);
+var contents = inputPaths.map(function(inputPath) {
var content = fs.readFileSync(inputPath, 'utf8')
-
- content = content
.replace(/[^\n]*\brequire[( ][^\n]+(?:\s*\n)?/g, '')
- .replace(/(\w+) = exports;/g, '$1 = {};\n')
- .replace(/= module\.exports =/g, '=')
- .trim()
+ .replace(/(\w+) = exports;/g, '$1 = {};')
+ .replace(/= module\.exports =/g, '=');
+
+ return content.replace(/'use strict';\s*/, '');
+});
- if (i > 0)
- content = '\n' + content.replace(/'use strict'\s*/, '')
- process.stdout.write(content + '\n')
-})
+console.log(contents.join('\n\n'));
View
@@ -1,26 +1,27 @@
#!/usr/bin/env node
-'use strict'
+'use strict';
-var args = process.argv.slice(2)
-var json = {}
+var args = process.argv.slice(2);
+var json = {};
-var stdin = ''
-process.stdin.resume()
-process.stdin.setEncoding('utf8')
+var stdin = '';
+process.stdin.resume();
+process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
- stdin += chunk
-})
+ stdin += chunk;
+});
process.stdin.on('end', function () {
args.forEach(function(arg) {
- var i = arg.indexOf('=')
- var key = arg.substr(0, i)
- var value = arg.substr(i + 1)
+ var i = arg.indexOf('=');
+ var key = arg.substr(0, i);
+ var value = arg.substr(i + 1);
- if (value === '-')
- value = stdin.replace(/\n$/, '')
+ if (value === '-') {
+ value = stdin.replace(/\n$/, '');
+ }
- json[key] = value
- })
+ json[key] = value;
+ });
- console.log(JSON.stringify(json))
-})
+ console.log(JSON.stringify(json));
+});
View
@@ -1,20 +1,20 @@
#!/usr/bin/env node
-'use strict'
+'use strict';
-var fs = require('fs')
-var Mustache = require('mustache')
+var fs = require('fs');
+var Mustache = require('mustache');
-var args = process.argv.slice(2)
+var args = process.argv.slice(2);
-var context = ''
-process.stdin.resume()
-process.stdin.setEncoding('utf8')
+var context = '';
+process.stdin.resume();
+process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
- context += chunk
-})
+ context += chunk;
+});
process.stdin.on('end', function () {
- context = JSON.parse(context)
+ context = JSON.parse(context);
- var content = fs.readFileSync(args[0], 'utf8')
- console.log(Mustache.render(content, context))
-})
+ var content = fs.readFileSync(args[0], 'utf8');
+ console.log(Mustache.render(content, context));
+});
@@ -6,11 +6,12 @@
* Released under the MIT license
*/
var roole = (function() {
+'use strict';
{{&content}}
roole.version = '{{&version}}'
return roole
-})()
+})();

0 comments on commit 49f24b1

Please sign in to comment.