Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mozilla/jpm into 147 r=@erikvold
Browse files Browse the repository at this point in the history
Conflicts:
	package.json
  • Loading branch information
erikvold committed Aug 26, 2014
2 parents 0bc72ea + d0f0003 commit ed278ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
7 changes: 3 additions & 4 deletions lib/init-input.js
@@ -1,5 +1,6 @@
var path = require("path");
var MIN_VERSION = require("./settings").MIN_VERSION;
var semver = require("semver");

module.exports = {
"title": prompt("title", "My Jetpack Addon", identity),
Expand Down Expand Up @@ -45,10 +46,8 @@ function sanitizeName (name) {
* @return {String}
*/

function sanitizeVersion (ver) {
if (/^\d+\.\d+\.\d+$/.test(ver))
return ver;
return "0.0.0";
function sanitizeVersion (version) {
return semver.valid(version) || "0.0.0";
}

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -32,7 +32,7 @@
"semver": "2.2.1",
"mozilla-version-comparator": "1.0.2",
"mozilla-toolkit-versioning": "0.0.1",
"jetpack-validation": "0.0.3",
"jetpack-validation": "0.0.4",
"winreg": "0.0.12",
"xml-escape": "1.0.0"
},
Expand Down
12 changes: 12 additions & 0 deletions test/functional/test.init.js
Expand Up @@ -130,6 +130,18 @@ describe("jpm init", function () {
});
});

it("allows non-numeric version strings", function (done) {
process.chdir(utils.tmpOutputDir);
var responses = ["", "", "v0.4.0-rc4", "", "", "", "", "", "yes"];

var proc = respond(exec("init"), responses.map(function (val) {
return val + '\n';
}));
proc.on("close", function () {
var manifest = JSON.parse(fs.readFileSync(path.join(utils.tmpOutputDir, "package.json"), "utf-8"));
expect(manifest.version).to.be.equal("0.4.0-rc4")
});
});
});

/**
Expand Down

0 comments on commit ed278ae

Please sign in to comment.