Skip to content

Commit

Permalink
For interoperability purposes, have the build API explicitly declare …
Browse files Browse the repository at this point in the history
…a current working directory. Revert to previous cwd on exit.
  • Loading branch information
doctyper committed Jun 3, 2013
1 parent 8ed5889 commit 810e8af
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@ module.exports = function (opts, callback) {

opts = opts || {};

var cwd = process.cwd();

var grunt = require("grunt");
var fs = require("fs");
var path = require("path");
var cp = require("child_process");
var fs = require("fs");

// Temporarily change working dir to Modernizr root
process.chdir(path.join(__dirname, ".."));

var Gruntfile = require("../Gruntfile")(grunt);
var Gruntfile = require(path.join(__dirname, "..", "Gruntfile"))(grunt);
var settings = grunt.config();

var verbose = (opts.verbose !== false);
delete opts.verbose;

if (typeof opts !== "undefined") {
var configPath = "./config-all.json";
var configPath = path.join(__dirname, "config-all.json");

if (fs.existsSync(configPath)) {
var modernizrConfig = grunt.file.readJSON(configPath);
Expand Down Expand Up @@ -44,6 +50,8 @@ module.exports = function (opts, callback) {
});
}

// Switch working directory back to original
process.chdir(cwd);
process.exit(code);
});
};

0 comments on commit 810e8af

Please sign in to comment.