Skip to content

Commit

Permalink
fix: Flatten sourceMap folder detection
Browse files Browse the repository at this point in the history
CodeQL was flagging the second `else if`.
Looked at code and inlined the single use so it's not executed if
first condition is true.
  • Loading branch information
nschonni committed May 11, 2020
1 parent 0d6c3cc commit 067ae70
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions bin/node-sass
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,11 @@ function getOptions(args, options) {
options.sourceMapOriginal = options.sourceMap;
}

// check if sourceMap path ends with .map to avoid isDirectory false-positive
var sourceMapIsDirectory = options.sourceMapOriginal.indexOf('.map', options.sourceMapOriginal.length - 4) === -1 && isDirectory(options.sourceMapOriginal);

if (options.sourceMapOriginal === 'true') {
options.sourceMap = options.dest + '.map';
} else if (!sourceMapIsDirectory) {
} else if (!(options.sourceMapOriginal.indexOf('.map', options.sourceMapOriginal.length - 4) === -1 && isDirectory(options.sourceMapOriginal))) {
options.sourceMap = path.resolve(options.sourceMapOriginal);
} else if (sourceMapIsDirectory) {
} else {
if (!options.directory) {
options.sourceMap = path.resolve(options.sourceMapOriginal, path.basename(options.dest) + '.map');
} else {
Expand Down

0 comments on commit 067ae70

Please sign in to comment.