-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2130 from gronke/enhancement/absolute-paths-1914
support absolute path in .bowerrc directory option
- Loading branch information
Showing
12 changed files
with
238 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function isPathAbsolute(filePath) { | ||
return filePath.charAt(0) === '/'; | ||
} | ||
|
||
module.exports = isPathAbsolute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
var path = require('path'); | ||
var isPathAbsolute = require('./isPathAbsolute'); | ||
|
||
function relativeToBaseDir(baseDir) { | ||
return function(filePath) { | ||
if(isPathAbsolute(filePath)) { | ||
return path.resolve(filePath); | ||
} else { | ||
return path.resolve(baseDir, filePath); | ||
} | ||
}; | ||
} | ||
|
||
module.exports = relativeToBaseDir; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
var path = require('path'); | ||
var Q = require('q'); | ||
var fs = require('fs'); | ||
var expect = require('expect.js'); | ||
var helpers = require('../helpers'); | ||
var createLink = require('../../lib/util/createLink'); | ||
|
||
describe('createLink', function () { | ||
|
||
var srcDir = new helpers.TempDir({ | ||
someFile: 'Hello World', | ||
someDirectory: { | ||
otherFile: 'Hello World' | ||
} | ||
}); | ||
|
||
var dstDir = new helpers.TempDir(); | ||
|
||
beforeEach(function() { | ||
srcDir.prepare(); | ||
dstDir.prepare(); | ||
}); | ||
|
||
it('creates a symlink to a file', function() { | ||
|
||
var src = path.join(srcDir.path, 'someFile'), | ||
dst = path.join(dstDir.path, 'someFile'); | ||
|
||
return createLink(src, dst) | ||
.then(function() { | ||
return Q.nfcall(fs.readlink, dst) | ||
.then(function(linkString) { | ||
expect(linkString).to.be.equal(src); | ||
}); | ||
}); | ||
}); | ||
|
||
it('throws an error when destination already exists', function() { | ||
|
||
var src = path.join(srcDir.path, 'someFile'), | ||
dst = path.join(dstDir.path); | ||
|
||
var deferred = Q.defer(); | ||
|
||
createLink(src, dst) | ||
.catch(function(err) { | ||
expect(err.code).to.be.equal('EEXIST'); | ||
deferred.resolve(); | ||
}) | ||
.then(function() { | ||
deferred.reject(); | ||
}); | ||
|
||
return deferred.promise; | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
var expect = require('expect.js'); | ||
var isPathAbsolute = require('../../lib/util/isPathAbsolute'); | ||
|
||
describe('isPathAbsolute', function () { | ||
|
||
it('returns true when a path begins with /', function() { | ||
expect(isPathAbsolute('/tmp/foo')).to.be.ok(); | ||
}); | ||
|
||
it('returns false when a path does not begin with /', function() { | ||
expect(isPathAbsolute('./tmp/foo')).to.not.be.ok(); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
var path = require('path'); | ||
var expect = require('expect.js'); | ||
var relativeToBaseDir = require('../../lib/util/relativeToBaseDir'); | ||
|
||
describe('relativeToBaseDir', function () { | ||
|
||
var joinOrReturnAbsolutePath = relativeToBaseDir('/tmp'); | ||
|
||
it('returns a partial function that joins paths of the partials first arguments', function() { | ||
expect(joinOrReturnAbsolutePath('foo')).to.be.equal(path.resolve('/tmp/foo')); | ||
expect(joinOrReturnAbsolutePath('./foo')).to.be.equal(path.resolve('/tmp/foo')); | ||
}); | ||
|
||
it('returns a partial function that returns it\'s first argument when it begins with /', function() { | ||
expect(joinOrReturnAbsolutePath('/foo')).to.be.equal(path.resolve('/foo')); | ||
expect(joinOrReturnAbsolutePath('/foo/bar')).to.be.equal(path.resolve('/foo/bar')); | ||
}); | ||
}); |