js-refactor
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -115,3 +115,3 @@ #! /usr/bin/env node | ||
const newline = line.substr(0, m.index) + line.substr(m.index).replace(dep, newDep); | ||
console.log('update file: %s\n %s\n->%s\n\n', file, line, newline); | ||
console.log('update file: %s\n %s\n->%s\n', file, line, newline); | ||
lines[ii] = newline; | ||
@@ -154,3 +154,3 @@ } | ||
const newline = line.substr(0, m.index) + line.substr(m.index).replace(dep, newDep); | ||
console.log('update file: %s\n %s\n->%s\n\n', file, line, newline); | ||
console.log('update file: %s\n %s\n->%s\n', file, line, newline); | ||
lines[ii] = newline; | ||
@@ -157,0 +157,0 @@ } |
@@ -25,9 +25,11 @@ 'use strict'; | ||
function addTrailingSlash(dir) { | ||
if (/\/$/.test(dir)) { | ||
return dir; | ||
} | ||
return `${dir}/`; | ||
} | ||
function isSuperDir(superDir, childDir) { | ||
let norm1 = _path2.default.normalize(superDir); | ||
const norm2 = _path2.default.normalize(childDir); | ||
if (!/\/$/.test(norm1)) { | ||
norm1 = `${norm1}/`; | ||
} | ||
return norm2.startsWith(norm1); | ||
return addTrailingSlash(childDir).startsWith(addTrailingSlash(superDir)); | ||
} |
{ | ||
"name": "js-refactor", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "mv file/directory around keeping require and import statements in sync", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -104,3 +104,3 @@ #! /usr/bin/env node | ||
const newline = line.substr(0, m.index) + line.substr(m.index).replace(dep, newDep); | ||
console.log('update file: %s\n %s\n->%s\n\n', file, line, newline); | ||
console.log('update file: %s\n %s\n->%s\n', file, line, newline); | ||
lines[ii] = newline; | ||
@@ -149,3 +149,3 @@ } | ||
line.substr(m.index).replace(dep, newDep); | ||
console.log('update file: %s\n %s\n->%s\n\n', file, line, newline); | ||
console.log('update file: %s\n %s\n->%s\n', file, line, newline); | ||
lines[ii] = newline; | ||
@@ -152,0 +152,0 @@ } |
@@ -9,9 +9,12 @@ import path from 'path'; | ||
export function isSuperDir(superDir, childDir) { | ||
let norm1 = path.normalize(superDir); | ||
const norm2 = path.normalize(childDir); | ||
if (!/\/$/.test(norm1)) { | ||
norm1 = `${norm1}/`; | ||
function addTrailingSlash(dir) { | ||
if (/\/$/.test(dir)) { | ||
return dir; | ||
} | ||
return norm2.startsWith(norm1); | ||
return `${dir}/`; | ||
} | ||
export function isSuperDir(superDir, childDir) { | ||
return addTrailingSlash(childDir) | ||
.startsWith(addTrailingSlash(superDir)); | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
314
70959