Complete some more tests related with the base resolver.

This commit is contained in:
André Cruz
2013-04-22 00:59:40 +01:00
parent 8bc7349635
commit bfc840d1a7
5 changed files with 195 additions and 13 deletions

View File

@@ -12,6 +12,8 @@ var glob = require('glob');
var config = require('../config');
var createError = require('../util/createError');
tmp.setGracefulCleanup();
var Resolver = function (source, options) {
options = options || {};
@@ -95,8 +97,8 @@ Resolver.prototype._createTempDir = function () {
.then(function () {
return Q.nfcall(tmp.dir, {
template: path.join(baseDir, this._name + '-XXXXXX'),
mode: parseInt('0777', 8) & (~process.umask())
//unsafeCleanup: true // TODO: don't forget enable this
mode: parseInt('0777', 8) & ~process.umask(),
unsafeCleanup: true
});
}.bind(this))
.then(function (dir) {
@@ -116,7 +118,7 @@ Resolver.prototype._readJson = function (dir) {
// Read it
return Q.nfcall(bowerJson.read, filename)
.then(null, function (err) {
throw createError('Something went wrong when reading "' + filename + '"', err.code, {
throw createError('Something went wrong while reading "' + filename + '"', err.code, {
details: err.message
});
});
@@ -128,11 +130,12 @@ Resolver.prototype._readJson = function (dir) {
Resolver.prototype._applyPkgMeta = function (meta) {
// Check if name defined in the json is different
// If so and if the name was "guessed", assume the json name
if (meta.name !== this._name) {
// If so and if the name was "guessed", assume the json name
if (this._guessedName) {
this._name = meta.name;
this.emit('name_change', this._name);
// Otherwise use/force the configured one
} else {
meta.name = this._name;
}