mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Replace internal tempfile name generator
- Drops "tempfile" module in favor of using the "tmp" external package. - Drop unused "rimraf-then" package.
This commit is contained in:
parent
48b846b13d
commit
0ed0a72c35
3 changed files with 94 additions and 147 deletions
|
@ -7,10 +7,9 @@ var should = require('should'),
|
||||||
readDirectory = require('../../server/utils/read-directory'),
|
readDirectory = require('../../server/utils/read-directory'),
|
||||||
readThemes = require('../../server/utils/read-themes'),
|
readThemes = require('../../server/utils/read-themes'),
|
||||||
gravatar = require('../../server/utils/gravatar'),
|
gravatar = require('../../server/utils/gravatar'),
|
||||||
tempfile = require('../utils/tempfile'),
|
tmp = require('tmp'),
|
||||||
utils = require('../../server/utils'),
|
utils = require('../../server/utils'),
|
||||||
join = require('path').join,
|
join = require('path').join,
|
||||||
rm = require('rimraf-then'),
|
|
||||||
fs = require('fs');
|
fs = require('fs');
|
||||||
|
|
||||||
// To stop jshint complaining
|
// To stop jshint complaining
|
||||||
|
@ -105,17 +104,17 @@ describe('Server Utilities', function () {
|
||||||
|
|
||||||
describe('parse-package-json', function () {
|
describe('parse-package-json', function () {
|
||||||
it('should parse valid package.json', function (done) {
|
it('should parse valid package.json', function (done) {
|
||||||
var pkgJson, tmpPath;
|
var pkgJson, tmpFile;
|
||||||
|
|
||||||
tmpPath = tempfile();
|
tmpFile = tmp.fileSync();
|
||||||
pkgJson = JSON.stringify({
|
pkgJson = JSON.stringify({
|
||||||
name: 'test',
|
name: 'test',
|
||||||
version: '0.0.0'
|
version: '0.0.0'
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.writeFileSync(tmpPath, pkgJson);
|
fs.writeSync(tmpFile.fd, pkgJson);
|
||||||
|
|
||||||
parsePackageJson(tmpPath)
|
parsePackageJson(tmpFile.name)
|
||||||
.then(function (pkg) {
|
.then(function (pkg) {
|
||||||
pkg.should.eql({
|
pkg.should.eql({
|
||||||
name: 'test',
|
name: 'test',
|
||||||
|
@ -125,188 +124,175 @@ describe('Server Utilities', function () {
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(done)
|
.catch(done)
|
||||||
.finally(function () {
|
.finally(tmpFile.removeCallback);
|
||||||
return rm(tmpPath);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail when name is missing', function (done) {
|
it('should fail when name is missing', function (done) {
|
||||||
var pkgJson, tmpPath;
|
var pkgJson, tmpFile;
|
||||||
|
|
||||||
tmpPath = tempfile();
|
tmpFile = tmp.fileSync();
|
||||||
pkgJson = JSON.stringify({
|
pkgJson = JSON.stringify({
|
||||||
version: '0.0.0'
|
version: '0.0.0'
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.writeFileSync(tmpPath, pkgJson);
|
fs.writeSync(tmpFile.fd, pkgJson);
|
||||||
|
|
||||||
parsePackageJson(tmpPath)
|
parsePackageJson(tmpFile.name)
|
||||||
.then(function () {
|
.then(function () {
|
||||||
done(new Error('parsePackageJson succeeded, but should\'ve failed'));
|
done(new Error('parsePackageJson succeeded, but should\'ve failed'));
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
err.message.should.equal('"name" or "version" is missing from theme package.json file.');
|
err.message.should.equal('"name" or "version" is missing from theme package.json file.');
|
||||||
err.context.should.equal(tmpPath);
|
err.context.should.equal(tmpFile.name);
|
||||||
err.help.should.equal('This will be required in future. Please see http://docs.ghost.org/themes/');
|
err.help.should.equal('This will be required in future. Please see http://docs.ghost.org/themes/');
|
||||||
|
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.finally(function () {
|
.catch(done)
|
||||||
return rm(tmpPath);
|
.finally(tmpFile.removeCallback);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail when version is missing', function (done) {
|
it('should fail when version is missing', function (done) {
|
||||||
var pkgJson, tmpPath;
|
var pkgJson, tmpFile;
|
||||||
|
|
||||||
tmpPath = tempfile();
|
tmpFile = tmp.fileSync();
|
||||||
pkgJson = JSON.stringify({
|
pkgJson = JSON.stringify({
|
||||||
name: 'test'
|
name: 'test'
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.writeFileSync(tmpPath, pkgJson);
|
fs.writeSync(tmpFile.fd, pkgJson);
|
||||||
|
|
||||||
parsePackageJson(tmpPath)
|
parsePackageJson(tmpFile.name)
|
||||||
.then(function () {
|
.then(function () {
|
||||||
done(new Error('parsePackageJson succeeded, but should\'ve failed'));
|
done(new Error('parsePackageJson succeeded, but should\'ve failed'));
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
err.message.should.equal('"name" or "version" is missing from theme package.json file.');
|
err.message.should.equal('"name" or "version" is missing from theme package.json file.');
|
||||||
err.context.should.equal(tmpPath);
|
err.context.should.equal(tmpFile.name);
|
||||||
err.help.should.equal('This will be required in future. Please see http://docs.ghost.org/themes/');
|
err.help.should.equal('This will be required in future. Please see http://docs.ghost.org/themes/');
|
||||||
|
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.finally(function () {
|
.catch(done)
|
||||||
return rm(tmpPath);
|
.finally(tmpFile.removeCallback);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail when JSON is invalid', function (done) {
|
it('should fail when JSON is invalid', function (done) {
|
||||||
var pkgJson, tmpPath;
|
var pkgJson, tmpFile;
|
||||||
|
|
||||||
tmpPath = tempfile();
|
tmpFile = tmp.fileSync();
|
||||||
pkgJson = '{name:"test"}';
|
pkgJson = '{name:"test"}';
|
||||||
|
|
||||||
fs.writeFileSync(tmpPath, pkgJson);
|
fs.writeSync(tmpFile.fd, pkgJson);
|
||||||
|
|
||||||
parsePackageJson(tmpPath)
|
parsePackageJson(tmpFile.name)
|
||||||
.then(function () {
|
.then(function () {
|
||||||
done(new Error('parsePackageJson succeeded, but should\'ve failed'));
|
done(new Error('parsePackageJson succeeded, but should\'ve failed'));
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
err.message.should.equal('Theme package.json file is malformed');
|
err.message.should.equal('Theme package.json file is malformed');
|
||||||
err.context.should.equal(tmpPath);
|
err.context.should.equal(tmpFile.name);
|
||||||
err.help.should.equal('This will be required in future. Please see http://docs.ghost.org/themes/');
|
err.help.should.equal('This will be required in future. Please see http://docs.ghost.org/themes/');
|
||||||
|
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.finally(function () {
|
.catch(done)
|
||||||
return rm(tmpPath);
|
.finally(tmpFile.removeCallback);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should fail when file is missing', function (done) {
|
it('should fail when file is missing', function (done) {
|
||||||
var tmpPath = tempfile();
|
var tmpFile = tmp.fileSync();
|
||||||
|
|
||||||
parsePackageJson(tmpPath)
|
tmpFile.removeCallback();
|
||||||
|
parsePackageJson(tmpFile.name)
|
||||||
.then(function () {
|
.then(function () {
|
||||||
done(new Error('parsePackageJson succeeded, but should\'ve failed'));
|
done(new Error('parsePackageJson succeeded, but should\'ve failed'));
|
||||||
})
|
})
|
||||||
.catch(function (err) {
|
.catch(function (err) {
|
||||||
err.message.should.equal('Could not read package.json file');
|
err.message.should.equal('Could not read package.json file');
|
||||||
err.context.should.equal(tmpPath);
|
err.context.should.equal(tmpFile.name);
|
||||||
|
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.finally(function () {
|
.catch(done);
|
||||||
return rm(tmpPath);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('read-directory', function () {
|
describe('read-directory', function () {
|
||||||
it('should read directory recursively', function (done) {
|
it('should read directory recursively', function (done) {
|
||||||
var themePath = tempfile();
|
var themePath = tmp.dirSync({unsafeCleanup: true});
|
||||||
|
|
||||||
// create example theme
|
// create example theme
|
||||||
fs.mkdirSync(themePath);
|
fs.mkdirSync(join(themePath.name, 'partials'));
|
||||||
fs.mkdirSync(join(themePath, 'partials'));
|
fs.writeFileSync(join(themePath.name, 'index.hbs'));
|
||||||
fs.writeFileSync(join(themePath, 'index.hbs'));
|
fs.writeFileSync(join(themePath.name, 'partials', 'navigation.hbs'));
|
||||||
fs.writeFileSync(join(themePath, 'partials', 'navigation.hbs'));
|
|
||||||
|
|
||||||
readDirectory(themePath)
|
readDirectory(themePath.name)
|
||||||
.then(function (tree) {
|
.then(function (tree) {
|
||||||
tree.should.eql({
|
tree.should.eql({
|
||||||
partials: {
|
partials: {
|
||||||
'navigation.hbs': join(themePath, 'partials', 'navigation.hbs')
|
'navigation.hbs': join(themePath.name, 'partials', 'navigation.hbs')
|
||||||
},
|
},
|
||||||
'index.hbs': join(themePath, 'index.hbs')
|
'index.hbs': join(themePath.name, 'index.hbs')
|
||||||
});
|
});
|
||||||
|
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(done)
|
.catch(done)
|
||||||
.finally(function () {
|
.finally(themePath.removeCallback);
|
||||||
return rm(themePath);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should read directory and ignore unneeded items', function (done) {
|
it('should read directory and ignore unneeded items', function (done) {
|
||||||
var themePath = tempfile();
|
var themePath = tmp.dirSync({unsafeCleanup: true});
|
||||||
|
|
||||||
// create example theme
|
// create example theme
|
||||||
fs.mkdirSync(themePath);
|
fs.mkdirSync(join(themePath.name, 'partials'));
|
||||||
fs.mkdirSync(join(themePath, 'partials'));
|
fs.writeFileSync(join(themePath.name, 'index.hbs'));
|
||||||
fs.writeFileSync(join(themePath, 'index.hbs'));
|
fs.writeFileSync(join(themePath.name, 'partials', 'navigation.hbs'));
|
||||||
fs.writeFileSync(join(themePath, 'partials', 'navigation.hbs'));
|
|
||||||
|
|
||||||
// create some trash
|
// create some trash
|
||||||
fs.mkdirSync(join(themePath, 'node_modules'));
|
fs.mkdirSync(join(themePath.name, 'node_modules'));
|
||||||
fs.mkdirSync(join(themePath, 'bower_components'));
|
fs.mkdirSync(join(themePath.name, 'bower_components'));
|
||||||
fs.mkdirSync(join(themePath, '.git'));
|
fs.mkdirSync(join(themePath.name, '.git'));
|
||||||
fs.writeFileSync(join(themePath, '.DS_Store'));
|
fs.writeFileSync(join(themePath.name, '.DS_Store'));
|
||||||
|
|
||||||
readDirectory(themePath, {ignore: ['.git']})
|
readDirectory(themePath.name, {ignore: ['.git']})
|
||||||
.then(function (tree) {
|
.then(function (tree) {
|
||||||
tree.should.eql({
|
tree.should.eql({
|
||||||
partials: {
|
partials: {
|
||||||
'navigation.hbs': join(themePath, 'partials', 'navigation.hbs')
|
'navigation.hbs': join(themePath.name, 'partials', 'navigation.hbs')
|
||||||
},
|
},
|
||||||
'index.hbs': join(themePath, 'index.hbs')
|
'index.hbs': join(themePath.name, 'index.hbs')
|
||||||
});
|
});
|
||||||
|
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(done)
|
.catch(done)
|
||||||
.finally(function () {
|
.finally(themePath.removeCallback);
|
||||||
return rm(themePath);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should read directory and parse package.json files', function (done) {
|
it('should read directory and parse package.json files', function (done) {
|
||||||
var themePath, pkgJson;
|
var themePath, pkgJson;
|
||||||
|
|
||||||
themePath = tempfile();
|
themePath = tmp.dirSync({unsafeCleanup: true});
|
||||||
pkgJson = JSON.stringify({
|
pkgJson = JSON.stringify({
|
||||||
name: 'test',
|
name: 'test',
|
||||||
version: '0.0.0'
|
version: '0.0.0'
|
||||||
});
|
});
|
||||||
|
|
||||||
// create example theme
|
// create example theme
|
||||||
fs.mkdirSync(themePath);
|
fs.mkdirSync(join(themePath.name, 'partials'));
|
||||||
fs.mkdirSync(join(themePath, 'partials'));
|
fs.writeFileSync(join(themePath.name, 'package.json'), pkgJson);
|
||||||
fs.writeFileSync(join(themePath, 'package.json'), pkgJson);
|
fs.writeFileSync(join(themePath.name, 'index.hbs'));
|
||||||
fs.writeFileSync(join(themePath, 'index.hbs'));
|
fs.writeFileSync(join(themePath.name, 'partials', 'navigation.hbs'));
|
||||||
fs.writeFileSync(join(themePath, 'partials', 'navigation.hbs'));
|
|
||||||
|
|
||||||
readDirectory(themePath)
|
readDirectory(themePath.name)
|
||||||
.then(function (tree) {
|
.then(function (tree) {
|
||||||
tree.should.eql({
|
tree.should.eql({
|
||||||
partials: {
|
partials: {
|
||||||
'navigation.hbs': join(themePath, 'partials', 'navigation.hbs')
|
'navigation.hbs': join(themePath.name, 'partials', 'navigation.hbs')
|
||||||
},
|
},
|
||||||
'index.hbs': join(themePath, 'index.hbs'),
|
'index.hbs': join(themePath.name, 'index.hbs'),
|
||||||
'package.json': {
|
'package.json': {
|
||||||
name: 'test',
|
name: 'test',
|
||||||
version: '0.0.0'
|
version: '0.0.0'
|
||||||
|
@ -316,78 +302,69 @@ describe('Server Utilities', function () {
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(done)
|
.catch(done)
|
||||||
.finally(function () {
|
.finally(themePath.removeCallback);
|
||||||
return rm(themePath);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should read directory and ignore invalid package.json files', function (done) {
|
it('should read directory and ignore invalid package.json files', function (done) {
|
||||||
var themePath, pkgJson;
|
var themePath, pkgJson;
|
||||||
|
|
||||||
themePath = tempfile();
|
themePath = tmp.dirSync({unsafeCleanup: true});
|
||||||
pkgJson = JSON.stringify({
|
pkgJson = JSON.stringify({
|
||||||
name: 'test'
|
name: 'test'
|
||||||
});
|
});
|
||||||
|
|
||||||
// create example theme
|
// create example theme
|
||||||
fs.mkdirSync(themePath);
|
fs.mkdirSync(join(themePath.name, 'partials'));
|
||||||
fs.mkdirSync(join(themePath, 'partials'));
|
fs.writeFileSync(join(themePath.name, 'package.json'), pkgJson);
|
||||||
fs.writeFileSync(join(themePath, 'package.json'), pkgJson);
|
fs.writeFileSync(join(themePath.name, 'index.hbs'));
|
||||||
fs.writeFileSync(join(themePath, 'index.hbs'));
|
fs.writeFileSync(join(themePath.name, 'partials', 'navigation.hbs'));
|
||||||
fs.writeFileSync(join(themePath, 'partials', 'navigation.hbs'));
|
|
||||||
|
|
||||||
readDirectory(themePath)
|
readDirectory(themePath.name)
|
||||||
.then(function (tree) {
|
.then(function (tree) {
|
||||||
tree.should.eql({
|
tree.should.eql({
|
||||||
partials: {
|
partials: {
|
||||||
'navigation.hbs': join(themePath, 'partials', 'navigation.hbs')
|
'navigation.hbs': join(themePath.name, 'partials', 'navigation.hbs')
|
||||||
},
|
},
|
||||||
'index.hbs': join(themePath, 'index.hbs'),
|
'index.hbs': join(themePath.name, 'index.hbs'),
|
||||||
'package.json': null
|
'package.json': null
|
||||||
});
|
});
|
||||||
|
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(done)
|
.catch(done)
|
||||||
.finally(function () {
|
.finally(themePath.removeCallback);
|
||||||
return rm(themePath);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('read-themes', function () {
|
describe('read-themes', function () {
|
||||||
it('should read directory and include only folders', function (done) {
|
it('should read directory and include only folders', function (done) {
|
||||||
var themesPath = tempfile();
|
var themesPath = tmp.dirSync({unsafeCleanup: true});
|
||||||
|
|
||||||
fs.mkdirSync(themesPath);
|
|
||||||
|
|
||||||
// create trash
|
// create trash
|
||||||
fs.writeFileSync(join(themesPath, 'casper.zip'));
|
fs.writeFileSync(join(themesPath.name, 'casper.zip'));
|
||||||
fs.writeFileSync(join(themesPath, '.DS_Store'));
|
fs.writeFileSync(join(themesPath.name, '.DS_Store'));
|
||||||
|
|
||||||
// create actual theme
|
// create actual theme
|
||||||
fs.mkdirSync(join(themesPath, 'casper'));
|
fs.mkdirSync(join(themesPath.name, 'casper'));
|
||||||
fs.mkdirSync(join(themesPath, 'casper', 'partials'));
|
fs.mkdirSync(join(themesPath.name, 'casper', 'partials'));
|
||||||
fs.writeFileSync(join(themesPath, 'casper', 'index.hbs'));
|
fs.writeFileSync(join(themesPath.name, 'casper', 'index.hbs'));
|
||||||
fs.writeFileSync(join(themesPath, 'casper', 'partials', 'navigation.hbs'));
|
fs.writeFileSync(join(themesPath.name, 'casper', 'partials', 'navigation.hbs'));
|
||||||
|
|
||||||
readThemes(themesPath)
|
readThemes(themesPath.name)
|
||||||
.then(function (tree) {
|
.then(function (tree) {
|
||||||
tree.should.eql({
|
tree.should.eql({
|
||||||
casper: {
|
casper: {
|
||||||
partials: {
|
partials: {
|
||||||
'navigation.hbs': join(themesPath, 'casper', 'partials', 'navigation.hbs')
|
'navigation.hbs': join(themesPath.name, 'casper', 'partials', 'navigation.hbs')
|
||||||
},
|
},
|
||||||
'index.hbs': join(themesPath, 'casper', 'index.hbs')
|
'index.hbs': join(themesPath.name, 'casper', 'index.hbs')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(done)
|
.catch(done)
|
||||||
.finally(function () {
|
.finally(themesPath.removeCallback);
|
||||||
return rm(themesPath);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -395,20 +372,18 @@ describe('Server Utilities', function () {
|
||||||
it('should return warnings for themes without package.json', function (done) {
|
it('should return warnings for themes without package.json', function (done) {
|
||||||
var themesPath, pkgJson;
|
var themesPath, pkgJson;
|
||||||
|
|
||||||
themesPath = tempfile();
|
themesPath = tmp.dirSync({unsafeCleanup: true});
|
||||||
pkgJson = JSON.stringify({
|
pkgJson = JSON.stringify({
|
||||||
name: 'casper',
|
name: 'casper',
|
||||||
version: '1.0.0'
|
version: '1.0.0'
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.mkdirSync(themesPath);
|
fs.mkdirSync(join(themesPath.name, 'casper'));
|
||||||
|
fs.mkdirSync(join(themesPath.name, 'invalid-casper'));
|
||||||
|
|
||||||
fs.mkdirSync(join(themesPath, 'casper'));
|
fs.writeFileSync(join(themesPath.name, 'casper', 'package.json'), pkgJson);
|
||||||
fs.mkdirSync(join(themesPath, 'invalid-casper'));
|
|
||||||
|
|
||||||
fs.writeFileSync(join(themesPath, 'casper', 'package.json'), pkgJson);
|
validateThemes(themesPath.name)
|
||||||
|
|
||||||
validateThemes(themesPath)
|
|
||||||
.then(function () {
|
.then(function () {
|
||||||
done(new Error('validateThemes succeeded, but should\'ve failed'));
|
done(new Error('validateThemes succeeded, but should\'ve failed'));
|
||||||
})
|
})
|
||||||
|
@ -422,23 +397,20 @@ describe('Server Utilities', function () {
|
||||||
|
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.finally(function () {
|
.catch(done)
|
||||||
return rm(themesPath);
|
.finally(themesPath.removeCallback);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return warning for theme with invalid package.json', function (done) {
|
it('should return warning for theme with invalid package.json', function (done) {
|
||||||
var themesPath, pkgJson;
|
var themesPath, pkgJson;
|
||||||
|
|
||||||
themesPath = tempfile();
|
themesPath = tmp.dirSync({unsafeCleanup: true});
|
||||||
pkgJson = '{"name":casper}';
|
pkgJson = '{"name":casper}';
|
||||||
|
|
||||||
fs.mkdirSync(themesPath);
|
fs.mkdirSync(join(themesPath.name, 'casper'));
|
||||||
|
fs.writeFileSync(join(themesPath.name, 'casper', 'package.json'), pkgJson);
|
||||||
|
|
||||||
fs.mkdirSync(join(themesPath, 'casper'));
|
validateThemes(themesPath.name)
|
||||||
fs.writeFileSync(join(themesPath, 'casper', 'package.json'), pkgJson);
|
|
||||||
|
|
||||||
validateThemes(themesPath)
|
|
||||||
.then(function () {
|
.then(function () {
|
||||||
done(new Error('validateThemes succeeded, but should\'ve failed'));
|
done(new Error('validateThemes succeeded, but should\'ve failed'));
|
||||||
})
|
})
|
||||||
|
@ -452,9 +424,8 @@ describe('Server Utilities', function () {
|
||||||
|
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.finally(function () {
|
.catch(done)
|
||||||
return rm(themesPath);
|
.finally(themesPath.removeCallback);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
/**
|
|
||||||
* Dependencies
|
|
||||||
*/
|
|
||||||
|
|
||||||
var join = require('path').join,
|
|
||||||
|
|
||||||
TMP_DIR = require('os').tmpdir();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a temporary file path
|
|
||||||
*/
|
|
||||||
|
|
||||||
function tempfile() {
|
|
||||||
var randomString = Math.random().toString(36).substring(7);
|
|
||||||
|
|
||||||
return join(TMP_DIR, randomString);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Expose `tempfile`
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports = tempfile;
|
|
|
@ -95,7 +95,6 @@
|
||||||
"mocha": "2.4.5",
|
"mocha": "2.4.5",
|
||||||
"nock": "7.1.0",
|
"nock": "7.1.0",
|
||||||
"rewire": "2.5.1",
|
"rewire": "2.5.1",
|
||||||
"rimraf-then": "1.0.0",
|
|
||||||
"should": "8.2.1",
|
"should": "8.2.1",
|
||||||
"should-http": "0.0.4",
|
"should-http": "0.0.4",
|
||||||
"sinon": "1.17.3",
|
"sinon": "1.17.3",
|
||||||
|
|
Loading…
Add table
Reference in a new issue