Fix some bugs when extracting archives, add some tests.

This commit is contained in:
André Cruz
2013-04-29 17:09:54 +01:00
parent 54b7920697
commit 2530c577dc
9 changed files with 36 additions and 13 deletions

Binary file not shown.

BIN
test/assets/package-zip.zip Normal file

Binary file not shown.

View File

@@ -130,7 +130,7 @@ describe('FsResolver', function () {
.done();
});
it('should not copy ignored paths', function (next) {
it('should not copy ignored paths (to speed up copying)', function (next) {
var resolver = new FsResolver(testPackage);
// Override the _applyPkgMeta function to prevent it from deleting ignored files
@@ -144,5 +144,29 @@ describe('FsResolver', function () {
})
.done();
});
it('should extract if source is an archive', function (next) {
var resolver = new FsResolver(path.resolve(__dirname, '../../assets/package-zip.zip'));
resolver.resolve()
.then(function (dir) {
expect(fs.existsSync(path.join(dir, 'foo.js'))).to.be(true);
expect(fs.existsSync(path.join(dir, 'package-zip.zip'))).to.be(false);
next();
})
.done();
});
it('should copy extracted folder contents if it\'s single to the root', function (next) {
var resolver = new FsResolver(path.resolve(__dirname, '../../assets/package-zip-folder.zip'));
resolver.resolve()
.then(function (dir) {
expect(fs.existsSync(path.join(dir, 'foo.js'))).to.be(true);
expect(fs.existsSync(path.join(dir, 'package-zip'))).to.be(false);
next();
})
.done();
});
});
});

View File

@@ -1,5 +1,8 @@
// Cleanup the uncaughtException added by the tmp module
// It messes with the mocha uncaughtException event to caught errors
// Please note that is the Resolver that calls tmp.setGracefulCleanup()
// so we need to require that before
require('../lib/resolve/Resolver');
process.removeAllListeners('uncaughtException');
require('./resolve/resolver');