Skip to content

Commit

Permalink
inline package version using genversion
Browse files Browse the repository at this point in the history
  • Loading branch information
stash committed Jul 30, 2018
1 parent 6300174 commit 55a41c1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/cookie.js
Expand Up @@ -36,7 +36,7 @@ var pubsuffix = require('./pubsuffix-psl');
var Store = require('./store').Store;
var MemoryCookieStore = require('./memstore').MemoryCookieStore;
var pathMatch = require('./pathMatch').pathMatch;
var VERSION = require('../package.json').version;
var VERSION = require('./version');

var punycode;
try {
Expand Down Expand Up @@ -1420,6 +1420,7 @@ CAN_BE_SYNC.forEach(function(method) {
CookieJar.prototype[method+'Sync'] = syncWrap(method);
});

exports.version = VERSION;
exports.CookieJar = CookieJar;
exports.Cookie = Cookie;
exports.Store = Store;
Expand Down
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -57,6 +57,7 @@
"lib"
],
"scripts": {
"version": "genversion lib/version.js && git add lib/version.js",
"test": "vows test/*_test.js",
"cover": "nyc --reporter=lcov --reporter=html vows test/*_test.js"
},
Expand All @@ -65,6 +66,7 @@
},
"devDependencies": {
"async": "^1.4.2",
"genversion": "^2.1.0",
"nyc": "^11.6.0",
"string.prototype.repeat": "^0.2.0",
"vows": "^0.8.1"
Expand Down
5 changes: 5 additions & 0 deletions test/api_test.js
Expand Up @@ -51,6 +51,11 @@ vows
assert.ok(CookieJar);
}
})
.addBatch({
"Version": function () {
assert.equal(tough.version, require('../package.json').version);
}
})
.addBatch({
"Constructor": {
topic: function () {
Expand Down
5 changes: 2 additions & 3 deletions test/jar_serialization_test.js
Expand Up @@ -37,7 +37,6 @@ var Cookie = tough.Cookie;
var CookieJar = tough.CookieJar;
var Store = tough.Store;
var MemoryCookieStore = tough.MemoryCookieStore;
var VERSION = require('../package.json').version;

var domains = ['example.com','www.example.com','example.net'];
var paths = ['/','/foo','/foo/bar'];
Expand Down Expand Up @@ -102,7 +101,7 @@ function setUp(context) {
function checkMetadata(serialized) {
assert.notEqual(serialized, null);
assert.isObject(serialized);
assert.equal(serialized.version, 'tough-cookie@'+VERSION);
assert.equal(serialized.version, 'tough-cookie@'+tough.version);
assert.equal(serialized.storeType, 'MemoryCookieStore');
assert.typeOf(serialized.rejectPublicSuffixes, 'boolean');
assert.isArray(serialized.cookies);
Expand Down Expand Up @@ -332,7 +331,7 @@ vows
},
"has expected metadata": function(err,jsonObj) {
assert.isNull(err);
assert.equal(jsonObj.version, 'tough-cookie@'+VERSION);
assert.equal(jsonObj.version, 'tough-cookie@'+tough.version);
assert.isTrue(jsonObj.rejectPublicSuffixes);
assert.equal(jsonObj.storeType, 'MemoryCookieStore');
},
Expand Down

0 comments on commit 55a41c1

Please sign in to comment.