Permalink
Browse files

minor --make stuff

- use eval rather than JSON.parse for reading the Makefile (I dislike the
  obligatory quotes in property names in JSON)

- locate files relative to the path of the Makefile
  • Loading branch information...
mishoo committed Jun 7, 2012
1 parent 7c15135 commit a3fcb0d2aa8b3b78193dbe2b59994a5b65d552a4
Showing with 4 additions and 3 deletions.
  1. +4 −3 bin/uglifyjs
View
@@ -2,7 +2,7 @@
// -*- js -*-
global.sys = require(/^v0\.[012]/.test(process.version) ? "sys" : "util");
-var fs = require("fs");
+var fs = require("fs"), path = require("path");
var uglify = require("../uglify-js"), // symlink ~/.node_libraries/uglify-js.js to ../uglify-js.js
consolidator = uglify.consolidator,
jsp = uglify.parser,
@@ -211,9 +211,10 @@ jsp.set_logger(function(msg){
if (options.make) {
options.out_same_file = false; // doesn't make sense in this case
- var makefile = JSON.parse(fs.readFileSync(filename || "Makefile.uglify.js").toString());
+ var makefile = global.eval("(" + fs.readFileSync(filename || "Makefile.uglify.js").toString() + ")");
+ var dir = path.dirname(filename);
output(makefile.files.map(function(file){
- var code = fs.readFileSync(file.name).toString();
+ var code = fs.readFileSync(path.join(dir, file.name)).toString();
if (file.module) {
code = "!function(exports, global){global = this;\n" + code + "\n;this." + file.module + " = exports;}({})";
}

0 comments on commit a3fcb0d

Please sign in to comment.