Skip to content

Commit dbe2eaa

Browse files
committed
Tidy up path splitting
1 parent 7c6da7a commit dbe2eaa

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

bin/lessc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
var path = require('path'),
44
fs = require('../lib/less-node/fs'),
5+
os = require("os"),
56
errno,
67
mkdirp;
78

@@ -152,13 +153,11 @@ function printUsage() {
152153
break;
153154
case 'include-path':
154155
if (checkArgFunc(arg, match[2])) {
155-
// support for both ; and : path separators
156-
// even on windows when using absolute paths with drive letters (eg C:\path:D:\path)
157-
var uniqueString = '!@#$%^&*()';
158-
options.paths = match[2].replace(/\b([a-z]):([\\\/])/gi, '$1' + uniqueString + '$2')
159-
.split(/[;:]/)
156+
// ; supported on windows.
157+
// : supported on windows and linux, excluding a drive letter like C:\ so C:\file:D:\file parses to 2
158+
options.paths = match[2]
159+
.split(os.type().match(/Windows/) ? /:(?!\\)|;/ : ':')
160160
.map(function(p) {
161-
p = p.replace(uniqueString, ':');
162161
if (p) {
163162
return path.resolve(process.cwd(), p);
164163
}

lib/less-node/lessc-helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var lessc_helper = {
2727
console.log("");
2828
console.log("options:");
2929
console.log(" -h, --help Prints help (this message) and exit.");
30-
console.log(" --include-path=PATHS Sets include paths. Separated by `:'. `;' also supported.");
30+
console.log(" --include-path=PATHS Sets include paths. Separated by `:'. `;' also supported on windows.");
3131
console.log(" -M, --depends Outputs a makefile import dependency list to stdout.");
3232
console.log(" --no-color Disables colorized output.");
3333
console.log(" --no-ie-compat Disables IE compatibility checks.");

lib/less-rhino/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,9 @@ function writeFile(filename, content) {
266266
if (checkArgFunc(arg, match[2])) {
267267
// support for both ; and : path separators
268268
// even on windows when using absolute paths with drive letters (eg C:\path:D:\path)
269-
var uniqueString = '!@#$%^&*()';
270-
options.paths = match[2].replace(/\b([a-z]):([\\\/])/gi, '$1' + uniqueString + '$2')
271-
.split(/[;:]/)
269+
options.paths = match[2]
270+
.split(os.type().match(/Windows/) ? /:(?!\\)|;/ : ':')
272271
.map(function(p) {
273-
p = p.replace(uniqueString, ':');
274272
if (p) {
275273
// return path.resolve(process.cwd(), p);
276274
return p;

0 commit comments

Comments
 (0)