Include only specified files in the NPM package
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -25,3 +25,4 @@ build/
|
||||
dist
|
||||
nbproject/
|
||||
*.iml
|
||||
.envrc
|
||||
|
||||
30
.npmignore
30
.npmignore
@@ -1,30 +0,0 @@
|
||||
dist/
|
||||
grunt/
|
||||
node_modules
|
||||
pkg/
|
||||
release_notes/
|
||||
spec/
|
||||
src/
|
||||
Gemfile
|
||||
Gemfile.lock
|
||||
Rakefile
|
||||
jasmine-core.gemspec
|
||||
.bundle/
|
||||
.gitignore
|
||||
.gitmodules
|
||||
.idea
|
||||
.jshintrc
|
||||
.rspec
|
||||
.sass-cache/
|
||||
.circleci
|
||||
scripts/
|
||||
*.sh
|
||||
*.py
|
||||
Gruntfile.js
|
||||
lib/jasmine-core.rb
|
||||
lib/jasmine-core/boot/
|
||||
lib/jasmine-core/spec
|
||||
lib/jasmine-core/version.rb
|
||||
lib/jasmine-core/*.py
|
||||
sauce_connect.log
|
||||
ci.js
|
||||
@@ -25,6 +25,13 @@
|
||||
"description": "Official packaging of Jasmine's core files for use by Node.js projects.",
|
||||
"homepage": "https://jasmine.github.io",
|
||||
"main": "./lib/jasmine-core.js",
|
||||
"files": [
|
||||
"MIT.LICENSE",
|
||||
"README.md",
|
||||
"images/*.{png,svg}",
|
||||
"lib/**/*.{js,css}",
|
||||
"package.json"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ejs": "^2.5.5",
|
||||
"eslint": "^6.8.0",
|
||||
|
||||
@@ -108,4 +108,56 @@ describe('npm package', function() {
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
it('does not have any unexpected files in the root directory', function() {
|
||||
var files = fs.readdirSync(this.tmpDir);
|
||||
expect(files).toEqual(['package']);
|
||||
});
|
||||
|
||||
it('does not have any unexpected files in the package directory', function() {
|
||||
var files = fs.readdirSync(path.resolve(this.tmpDir, 'package'));
|
||||
files.sort();
|
||||
expect(files).toEqual([
|
||||
'MIT.LICENSE',
|
||||
'README.md',
|
||||
'images',
|
||||
'lib',
|
||||
'package.json'
|
||||
]);
|
||||
});
|
||||
|
||||
it('only has images in the images dir', function() {
|
||||
var files = fs.readdirSync(path.resolve(this.tmpDir, 'package/images')),
|
||||
i;
|
||||
|
||||
for (i = 0; i < files.length; i++) {
|
||||
expect(files[i]).toMatch(/\.(svg|png)$/);
|
||||
}
|
||||
});
|
||||
|
||||
it('only has JS and CSS files in the lib dir', function() {
|
||||
var files = [],
|
||||
i;
|
||||
|
||||
function getFiles(dir) {
|
||||
var dirents = fs.readdirSync(dir, { withFileTypes: true }),
|
||||
j;
|
||||
|
||||
for (j = 0; j < dirents.length; j++) {
|
||||
dirent = dirents[j];
|
||||
|
||||
if (dirent.isDirectory()) {
|
||||
getFiles(path.resolve(dir, dirent.name));
|
||||
} else {
|
||||
files.push(path.resolve(dir, dirent.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getFiles(path.resolve(this.tmpDir, 'package/lib'));
|
||||
|
||||
for (i = 0; i < files.length; i++) {
|
||||
expect(files[i]).toMatch(/\.(js|css)$/);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user