Use OS-agnostic filepath verification

This commit is contained in:
Brandon Freitag 2016-01-12 02:08:43 -08:00
parent bceb066c5c
commit fd27d85317

View File

@ -29,9 +29,11 @@ function _ln(options, source, dest) {
}
source = String(source);
var sourcePath = path.normalize(source).replace(RegExp(path.sep + '$'), '');
var isAbsolute = (path.resolve(source) === sourcePath);
dest = path.resolve(process.cwd(), String(dest));
if (!fs.existsSync(source) && !path.isAbsolute(source) && !fs.existsSync(path.dirname(dest) + '/' + source)) {
if ((isAbsolute && !fs.existsSync(sourcePath)) || !fs.existsSync(path.resolve(process.cwd(), path.dirname(dest), source))) {
common.error('Source file does not exist', true);
}