mirror of https://github.com/status-im/js-waku.git
Apply import update logic for external modules
This commit is contained in:
parent
5ca3957b39
commit
53a3f7fcbf
|
@ -36,8 +36,16 @@ function fixImportsAtFile(filePath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const [_, importPath] = l.split(`"`);
|
const [_, importPath] = l.split(`"`);
|
||||||
const fullPath = path.join(filePath, "..", importPath);
|
let exists = true;
|
||||||
const exists = fs.existsSync(fullPath);
|
let fullPath;
|
||||||
|
if (importPath.startsWith(".")) {
|
||||||
|
fullPath = path.join(filePath, "..", importPath);
|
||||||
|
exists = fs.existsSync(fullPath);
|
||||||
|
} else {
|
||||||
|
fullPath = path.join(process.cwd(), "node_modules", importPath);
|
||||||
|
exists = fs.existsSync(fullPath);
|
||||||
|
}
|
||||||
|
|
||||||
if (exists === false) {
|
if (exists === false) {
|
||||||
console.log("Update ", l);
|
console.log("Update ", l);
|
||||||
return l.replace(IMPORT_REGEXP, JUST_ADD_AN_EXTENSION);
|
return l.replace(IMPORT_REGEXP, JUST_ADD_AN_EXTENSION);
|
||||||
|
|
Loading…
Reference in New Issue