Don't use hardcoded temporary directory paths

This commit is contained in:
Steve Gravrock
2015-02-22 15:32:39 -08:00
parent 8c59875afe
commit 0776146d3b
2 changed files with 4 additions and 6 deletions

View File

@@ -28,6 +28,7 @@
"grunt-contrib-jshint": "~0.7.0", "grunt-contrib-jshint": "~0.7.0",
"jasmine": "https://github.com/jasmine/jasmine-npm/archive/master.tar.gz", "jasmine": "https://github.com/jasmine/jasmine-npm/archive/master.tar.gz",
"load-grunt-tasks": "^0.4.0", "load-grunt-tasks": "^0.4.0",
"shelljs": "~0.1.4" "shelljs": "~0.1.4",
"temp": "~0.8.1"
} }
} }

View File

@@ -1,5 +1,6 @@
describe('npm package', function() { describe('npm package', function() {
var path = require('path'), var path = require('path'),
temp = require('temp').track(),
fs = require('fs'); fs = require('fs');
beforeAll(function() { beforeAll(function() {
@@ -7,9 +8,7 @@ describe('npm package', function() {
pack = shell.exec('npm pack', { silent: true }); pack = shell.exec('npm pack', { silent: true });
this.tarball = pack.output.split('\n')[0]; this.tarball = pack.output.split('\n')[0];
this.tmpDir = '/tmp/jasmine-core'; this.tmpDir = temp.mkdirSync(); // automatically deleted on exit
fs.mkdirSync(this.tmpDir);
var untar = shell.exec('tar -xzf ' + this.tarball + ' -C ' + this.tmpDir, { silent: true }); var untar = shell.exec('tar -xzf ' + this.tarball + ' -C ' + this.tmpDir, { silent: true });
expect(untar.code).toBe(0); expect(untar.code).toBe(0);
@@ -44,8 +43,6 @@ describe('npm package', function() {
}; };
fs.unlink(this.tarball); fs.unlink(this.tarball);
fs.readdirSync(this.tmpDir).forEach(cleanup.bind(null, this.tmpDir));
fs.rmdirSync(this.tmpDir);
}); });
it('has a root path', function() { it('has a root path', function() {