Skip to content

Commit

Permalink
Improve last commit, fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
satazor committed Nov 30, 2012
1 parent a3fa306 commit 4b134a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/core/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ Package.prototype.download = function () {
src.path = this.assetUrl;
}

tmp.dir({ prefix: 'bower-' + this.name + '-', mode: parseInt('0777', 8) }, function (err, tmpPath) {
tmp.dir({ prefix: 'bower-' + this.name + '-', mode: parseInt('0777', 8) & (~process.umask()) }, function (err, tmpPath) {
var file = fs.createWriteStream(path.join((this.path = tmpPath), 'index' + this.assetType));

req.get(src, function (res) {
Expand Down
8 changes: 6 additions & 2 deletions test/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,10 @@ describe('package', function () {
pkg.on('install', function () {
async.map([pkg.localPath, cachePath], fs.stat, function (err, results) {
if (err) throw new Error(err);
var mode0777 = parseInt('0777', 8);
var expectedMode = mode0777 & (~process.umask());
assert.equal(results[0].mode, results[1].mode);
assert.equal(results[0].mode, 16822); // means 0777
assert((results[0].mode & expectedMode) === expectedMode || results[0].mode === 16822); // 16822 is for windows
next();
});
});
Expand All @@ -336,7 +338,9 @@ describe('package', function () {
pkg.on('install', function () {
fs.stat(pkg.localPath, function (err, stat) {
if (err) throw new Error(err);
assert.equal(stat.mode, 16822); // means 0777
var mode0777 = parseInt('0777', 8);
var expectedMode = mode0777 & (~process.umask());
assert((stat.mode & expectedMode) === expectedMode || stat.mode === 16822); // 16822 is for windows
next();
});
});
Expand Down

0 comments on commit 4b134a3

Please sign in to comment.