mirror of
https://github.com/bower/bower.git
synced 2026-02-11 14:34:58 -05:00
Fix issues in windows.
This commit is contained in:
@@ -97,7 +97,7 @@ Resolver.prototype._createTempDir = function () {
|
||||
.then(function () {
|
||||
return Q.nfcall(tmp.dir, {
|
||||
template: path.join(baseDir, this._name + '-XXXXXX'),
|
||||
mode: parseInt('0777', 8) & ~process.umask(),
|
||||
mode: 0777 & ~process.umask(),
|
||||
unsafeCleanup: true
|
||||
});
|
||||
}.bind(this))
|
||||
|
||||
@@ -25,7 +25,8 @@ GitFsResolver.prototype._resolveSelf = function () {
|
||||
return this._findResolution()
|
||||
.then(this._readJson.bind(this, this._source))
|
||||
.then(this._copy.bind(this))
|
||||
.then(this._checkout.bind(this));
|
||||
.then(this._checkout.bind(this))
|
||||
.then(this._cleanup.bind(this));
|
||||
};
|
||||
|
||||
// -----------------
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
var util = require('util');
|
||||
var path = require('path');
|
||||
var Q = require('q');
|
||||
var semver = require('semver');
|
||||
var chmodr = require('chmodr');
|
||||
var rimraf = require('rimraf');
|
||||
var mout = require('mout');
|
||||
var Resolver = require('../Resolver');
|
||||
var createError = require('../../util/createError');
|
||||
@@ -15,7 +18,8 @@ util.inherits(GitResolver, Resolver);
|
||||
|
||||
GitResolver.prototype._resolveSelf = function () {
|
||||
return this._findResolution()
|
||||
.then(this._checkout.bind(this));
|
||||
.then(this._checkout.bind(this))
|
||||
.then(this._cleanup.bind(this));
|
||||
};
|
||||
|
||||
GitResolver.prototype.hasNew = function (canonicalPkg) {
|
||||
@@ -95,7 +99,8 @@ GitResolver.prototype._findResolution = function (target) {
|
||||
// Otherwise, assume target is a branch
|
||||
return self.fetchHeads(this._source)
|
||||
.then(function (heads) {
|
||||
if (!heads[target]) {
|
||||
// Use hasOwn because a branch could have a name like "hasOwnProperty"
|
||||
if (mout.object.hasOwn(heads, target)) {
|
||||
branches = Object.keys(heads);
|
||||
throw createError('Branch "' + target + '" does not exist', 'ENORESTARGET', {
|
||||
details: !branches.length ?
|
||||
@@ -108,6 +113,22 @@ GitResolver.prototype._findResolution = function (target) {
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
GitResolver.prototype._cleanup = function () {
|
||||
var gitFolder = path.join(this._tempDir, '.git');
|
||||
|
||||
// Remove the .git folder
|
||||
// Note that on windows, we need to chmod to 0777 before due to a bug in git
|
||||
// See: https://github.com/isaacs/rimraf/issues/19
|
||||
if (process.platform === 'win32') {
|
||||
return Q.nfcall(chmodr, gitFolder, 0777)
|
||||
.then(function () {
|
||||
return Q.nfcall(rimraf, gitFolder);
|
||||
});
|
||||
} else {
|
||||
return Q.nfcall(rimraf, gitFolder);
|
||||
}
|
||||
};
|
||||
|
||||
GitResolver.prototype._savePkgMeta = function (meta) {
|
||||
// Save resolution to be used in hasNew later
|
||||
meta._resolution = this._resolution;
|
||||
|
||||
Reference in New Issue
Block a user