From e7c61afd39fa7b684fd0d7691155c698ad0b4df5 Mon Sep 17 00:00:00 2001 From: Christopher Monsanto Date: Mon, 27 Jul 2020 22:17:12 -0400 Subject: [PATCH] deploy: hookup new path functions to import (now copy) --- tools/deploy/import.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tools/deploy/import.ts b/tools/deploy/import.ts index f3428084..63234ae7 100644 --- a/tools/deploy/import.ts +++ b/tools/deploy/import.ts @@ -1,7 +1,7 @@ import fs from 'fs'; import vm from 'vm'; -import pathlib from 'path'; +import * as pathlib from './path.js'; export function imp(files: string[], code : string) { const script = new vm.Script(code); @@ -9,16 +9,13 @@ export function imp(files: string[], code : string) { const results = []; for (const file of files) { const parsed = pathlib.parse(file); - const obj = {dir: parsed.dir, - base: parsed.name, - ext: parsed.ext === "" ? null : parsed.ext.slice(1) - }; - const output = script.runInNewContext({path: obj, ...obj}); - if (typeof output === 'string') { - const dest = pathlib.format({name: output, ext: parsed.ext}); + const delta = script.runInNewContext({path: parsed, ...parsed}); + if (delta) { + const result = pathlib.path(parsed, delta); + const dest = pathlib.format(result); results.push({src: file, dst: dest}); } else { - throw new Error(`result of eval on ${file} not string`); + throw new Error(`result of eval on ${file} falsy`); } } return results;