Skip to content

Commit 2fb98dd

Browse files
committed
Include only specified files in the NPM package
1 parent 641c33d commit 2fb98dd

File tree

4 files changed

+72
-6
lines changed

4 files changed

+72
-6
lines changed

.npmignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
"test": "node ./bin/jasmine.js",
1919
"posttest": "eslint \"bin/**/*.js\" \"lib/**/*.js\" \"spec/**/*.js\""
2020
},
21+
"files": [
22+
"bin",
23+
"lib",
24+
"MIT.LICENSE",
25+
"package.json",
26+
"README.md"
27+
],
2128
"dependencies": {
2229
"glob": "^7.1.6",
2330
"jasmine-core": "~3.7.0"
@@ -29,7 +36,8 @@
2936
"grunt": "^1.0.4",
3037
"grunt-cli": "^1.3.2",
3138
"shelljs": "^0.8.3",
32-
"slash": "^3.0.0"
39+
"slash": "^3.0.0",
40+
"temp": "^0.9.4"
3341
},
3442
"eslintConfig": {
3543
"parserOptions": {

spec/npm_package_spec.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
describe('npm package', function() {
2+
var path = require('path'),
3+
temp = require('temp').track(),
4+
fs = require('fs');
5+
6+
beforeAll(function() {
7+
var shell = require('shelljs'),
8+
pack = shell.exec('npm pack', { silent: true });
9+
10+
this.tarball = pack.stdout.split('\n')[0];
11+
this.tmpDir = temp.mkdirSync(); // automatically deleted on exit
12+
13+
var untar = shell.exec('tar -xzf ' + this.tarball + ' -C ' + this.tmpDir, {
14+
silent: true
15+
});
16+
expect(untar.code).toBe(0);
17+
});
18+
19+
beforeEach(function() {
20+
jasmine.addMatchers({
21+
toExistInPath: function() {
22+
return {
23+
compare: function(actual, expected) {
24+
var fullPath = path.resolve(expected, actual);
25+
return {
26+
pass: fs.existsSync(fullPath)
27+
};
28+
}
29+
};
30+
}
31+
});
32+
});
33+
34+
afterAll(function() {
35+
fs.unlinkSync(this.tarball);
36+
});
37+
38+
it('has a jasmine script', function() {
39+
expect('package/bin/jasmine.js').toExistInPath(this.tmpDir);
40+
});
41+
42+
it('has a jasmine module', function() {
43+
expect('package/lib/jasmine.js').toExistInPath(this.tmpDir);
44+
});
45+
46+
it('contains only the expected root entries', function() {
47+
const files = fs.readdirSync(this.tmpDir);
48+
expect(files).toEqual(['package']);
49+
});
50+
51+
it('contains only the expected entries in the package dir', function() {
52+
const files = fs.readdirSync(path.resolve(this.tmpDir, 'package'));
53+
files.sort();
54+
expect(files).toEqual([
55+
'MIT.LICENSE',
56+
'README.md',
57+
'bin',
58+
'lib',
59+
'package.json',
60+
]);
61+
});
62+
});

spec/support/jasmine.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"loader_spec.js",
88
"manager_spec.js",
99
"run_spec.js",
10+
"npm_package_spec.js",
1011
"reporters/**/*[sS]pec.js",
1112
"filters/**/*[sS]pec.js"
1213
],

0 commit comments

Comments
 (0)