Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,12 @@ export async function importPath(
filepath: string,
origin = filepath
): Promise<void> {
const ext = path.extname(filepath)
const base = path.basename(filepath)
const dir = path.dirname(filepath)
const { ext, base, dir } = path.parse(filepath)

if (ext === '') {
const tmpFilename = fs.existsSync(`${filepath}.mjs`)
? `${base}-${randomId()}.mjs`
: `${base}.mjs`
const tmpFilename = fs.existsSync(filepath + EXT)
? base + '-' + randomId() + EXT
: base + EXT

return writeAndImport(
await fs.readFile(filepath),
Expand All @@ -205,7 +203,7 @@ export async function importPath(
if (ext === '.md') {
return writeAndImport(
transformMarkdown(await fs.readFile(filepath)),
path.join(dir, base + '.mjs'),
path.join(dir, base + EXT),
origin
)
}
Expand Down
4 changes: 2 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function preferLocalBin(
// }

export function quote(arg: string): string {
if (/^[a-z0-9/_.\-@:=]+$/i.test(arg) || arg === '') {
if (/^[\w/.-@:=]+$/.test(arg) || arg === '') {
return arg
}
return (
Expand All @@ -120,7 +120,7 @@ export function quote(arg: string): string {
}

export function quotePowerShell(arg: string): string {
if (/^[a-z0-9/_.\-]+$/i.test(arg) || arg === '') {
if (/^[\w/.-]+$/.test(arg) || arg === '') {
return arg
}
return `'` + arg.replace(/'/g, "''") + `'`
Expand Down