mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +00:00
Don't prefix paths with drive letters with dots in mkdirpSync. [closes #238]
Former-commit-id: dd0c8d7b1906210e5f26604d4149ba542727c78d
This commit is contained in:
@@ -9,6 +9,9 @@
|
|||||||
/** Load other modules */
|
/** Load other modules */
|
||||||
var _ = require('../lodash.js');
|
var _ = require('../lodash.js');
|
||||||
|
|
||||||
|
/** Used to indicate if running in Windows */
|
||||||
|
var isWindows = process.platform == 'win32';
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,7 +20,7 @@
|
|||||||
* @memberOf util.path
|
* @memberOf util.path
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
var sep = path.sep || (process.platform == 'win32' ? '\\' : '/');
|
var sep = path.sep || (isWindows ? '\\' : '/');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The escaped path separator used for inclusion in RegExp strings.
|
* The escaped path separator used for inclusion in RegExp strings.
|
||||||
@@ -27,6 +30,9 @@
|
|||||||
*/
|
*/
|
||||||
var sepEscaped = sep.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
var sepEscaped = sep.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||||
|
|
||||||
|
/** Used to determine if a path is prefixed with a drive letter, dot, or slash */
|
||||||
|
var rePrefixed = RegExp('^(?:' + (isWindows ? '[a-zA-Z]:|' : '') + '\\.?)' + sepEscaped);
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,7 +45,7 @@
|
|||||||
*/
|
*/
|
||||||
function mkdirpSync(dirname, mode) {
|
function mkdirpSync(dirname, mode) {
|
||||||
// ensure relative paths are prefixed with `./`
|
// ensure relative paths are prefixed with `./`
|
||||||
if (!RegExp('^\\.?' + sepEscaped).test(dirname)) {
|
if (!rePrefixed.test(dirname)) {
|
||||||
dirname = '.' + sep + dirname;
|
dirname = '.' + sep + dirname;
|
||||||
}
|
}
|
||||||
dirname.split(sep).reduce(function(currPath, segment) {
|
dirname.split(sep).reduce(function(currPath, segment) {
|
||||||
|
|||||||
Reference in New Issue
Block a user