From 1d8ba2753541d963d519d4f4318a3dfc825a860b Mon Sep 17 00:00:00 2001 From: Nikola Date: Tue, 17 May 2022 17:56:05 +0200 Subject: [PATCH] allow require & direct import This PR would allow for require('file') and import 'file'. --- cli.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cli.js b/cli.js index 43ab8b7..d54e517 100755 --- a/cli.js +++ b/cli.js @@ -42,7 +42,7 @@ const fixedfiles = [] const gitcommands = ['#!/bin/bash'] -const reg = new RegExp(/from\s+['"](.*)['"]/) +const reg = new RegExp(/(import\s+|from\s+|require\()['"](.*)['"]/) const [, , ...args] = process.argv const target = args[0] || 'src' @@ -169,9 +169,9 @@ const pass1 = () => { let newline = line const m = line.match(reg) if (m) { - const newfile = camelCaseToKebab(m[1]) + const newfile = camelCaseToKebab(m[2]) if (m[1] !== newfile) { - newline = line.replace(reg, `from '${newfile}'`) + newline = line.replace(reg, `${m[1]}'${newfile}'`) dirty = true } }