From b65fa7bcc92a26bf0c18e3ad4b437c9a01955436 Mon Sep 17 00:00:00 2001 From: Marek Piasecki Date: Sun, 15 Jan 2023 17:59:57 +0100 Subject: [PATCH] should work prototype of pro-router init; to be tested later; fix exporting helpers --- bin/pro-router.imba | 16 ++++++++-------- src/helpers.imba | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/pro-router.imba b/bin/pro-router.imba index c06e626..c45cfb8 100644 --- a/bin/pro-router.imba +++ b/bin/pro-router.imba @@ -11,7 +11,7 @@ def run(steps) C "[ {result.status ? "OK" : "FAILED"} ] {result.message}" def addProRouterViewsPlugin() - const configFile = file "./vite.config.js" + const configFile = file "vite.config.js" const configContent = try nfs.readFileSync(configFile, 'utf-8') return { desc: "Adding proRouterViews() plugin to vite.config.js", @@ -28,26 +28,26 @@ def addProRouterViewsPlugin() } def generateRouterFile() - const routerFile = file './src/router.imba' - const routerContent = try nfs.readFileSync(routerFile, 'utf-8') + const destinationFile = file 'src/router.imba' + const destinationContent = try nfs.readFileSync(destinationFile, 'utf-8') return { desc: "Generating src/router.imba file" run: do - if routerContent - if /R\.init/.test(routerContent) + if destinationContent + if /R\.init/.test(destinationContent) return status: true, message: "router seems to be ALREADY on place" else return status: false, message: "file already exist" else try - nfs.cp source: './node_modules/pro-router-imba2/src/router.imba', destination: './src/' + const routerContent = nfs.readFileSync(file('node_modules/pro-router-imba2/src/router.imba'), 'utf-8') + nfs.writeFileSync(destinationFile, routerContent.replace("./", 'pro-router-imba2')) + nfs.cp source: 'node_modules/pro-router-imba2/src/router.imba', destination: './src/' return status: true, message: "generated successfuly" catch return status: false, message: 'unable to copy router.imba template' } -C nfs - if process.argv.slice(2) == "init" run([addProRouterViewsPlugin(), generateRouterFile()]) else diff --git a/src/helpers.imba b/src/helpers.imba index 4462d19..34498bd 100644 --- a/src/helpers.imba +++ b/src/helpers.imba @@ -6,7 +6,7 @@ import reject from 'lodash.reject' import toPairs from 'lodash.topairs' import flatten from 'lodash.flatten' -export helpers = { +export const helpers = { compact: compact fromPairs: fromPairs chunk: chunk