Skip to content
Permalink
Browse files

Update: Ask for `commonjs` under config init (fixes #3553)

  • Loading branch information...
gyandeeps committed Dec 28, 2015
1 parent e8939e4 commit 505076812e2f83c3b2e35e5e138e17782924350f
Showing with 27 additions and 1 deletion.
  1. +14 −0 lib/config/config-initializer.js
  2. +13 −1 tests/lib/config/config-initializer.js
@@ -84,6 +84,9 @@ function processAnswers(answers) {
if (answers.es6) {
config.env.es6 = true;
}
if (answers.commonjs) {
config.env.commonjs = true;
}
answers.env.forEach(function(env) {
config.env[env] = true;
});
@@ -198,6 +201,17 @@ function promptUser(callback) {
default: ["browser"],
choices: [{name: "Node", value: "node"}, {name: "Browser", value: "browser"}]
},
{
type: "confirm",
name: "commonjs",
message: "Do you use CommonJS?",
default: false,
when: function(answers) {
return answers.env.some(function(env) {
return env === "browser";
});
}
},
{
type: "confirm",
name: "jsx",
@@ -32,7 +32,8 @@ describe("configInitializer", function() {
env: ["browser"],
jsx: false,
react: false,
format: "JSON"
format: "JSON",
commonjs: false
};
});

@@ -99,6 +100,17 @@ describe("configInitializer", function() {
init.getConfigForStyleGuide("non-standard");
}, "You referenced an unsupported guide.");
});

it("should not use commonjs by default", function() {
var config = init.processAnswers(answers);
assert.isUndefined(config.env.commonjs);
});

it("should use commonjs when set", function() {
answers.commonjs = true;
var config = init.processAnswers(answers);
assert.isTrue(config.env.commonjs);
});
});

});

0 comments on commit 5050768

Please sign in to comment.
You can’t perform that action at this time.