-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include only specified files in the NPM package
- Loading branch information
Showing
4 changed files
with
72 additions
and
6 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
describe('npm package', function() { | ||
var path = require('path'), | ||
temp = require('temp').track(), | ||
fs = require('fs'); | ||
|
||
beforeAll(function() { | ||
var shell = require('shelljs'), | ||
pack = shell.exec('npm pack', { silent: true }); | ||
|
||
this.tarball = pack.stdout.split('\n')[0]; | ||
this.tmpDir = temp.mkdirSync(); // automatically deleted on exit | ||
|
||
var untar = shell.exec('tar -xzf ' + this.tarball + ' -C ' + this.tmpDir, { | ||
silent: true | ||
}); | ||
expect(untar.code).toBe(0); | ||
}); | ||
|
||
beforeEach(function() { | ||
jasmine.addMatchers({ | ||
toExistInPath: function() { | ||
return { | ||
compare: function(actual, expected) { | ||
var fullPath = path.resolve(expected, actual); | ||
return { | ||
pass: fs.existsSync(fullPath) | ||
}; | ||
} | ||
}; | ||
} | ||
}); | ||
}); | ||
|
||
afterAll(function() { | ||
fs.unlinkSync(this.tarball); | ||
}); | ||
|
||
it('has a jasmine script', function() { | ||
expect('package/bin/jasmine.js').toExistInPath(this.tmpDir); | ||
}); | ||
|
||
it('has a jasmine module', function() { | ||
expect('package/lib/jasmine.js').toExistInPath(this.tmpDir); | ||
}); | ||
|
||
it('contains only the expected root entries', function() { | ||
const files = fs.readdirSync(this.tmpDir); | ||
expect(files).toEqual(['package']); | ||
}); | ||
|
||
it('contains only the expected entries in the package dir', function() { | ||
const files = fs.readdirSync(path.resolve(this.tmpDir, 'package')); | ||
files.sort(); | ||
expect(files).toEqual([ | ||
'MIT.LICENSE', | ||
'README.md', | ||
'bin', | ||
'lib', | ||
'package.json', | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters