Code Reuse #1381
Unanswered
josephcrawfordSRH
asked this question in
Q&A
Code Reuse
#1381
Replies: 1 comment 3 replies
-
The convention is to add shared/library code to file in // ~/.kenv/lib/my-lib.ts
import "@johnlindquist/kit"
export const getName = async () => {
return await arg("Enter name")
} Then import them into scripts: // ~/.kenv/scripts/my-script.ts
import "@johnlindquist/kit"
import { getName } from "../lib/my-lib"
let name = await getName() |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am wondering if a script can be a folder such as
script-name/script-1.js
, script-name/script-2.js`? I will explain my use case. I have a script that can be executed by shortcut and one of the questions is whether or not I want to open a new ide window. I would prefter to have a base-script with a method that script-1 and script-2 could import passing a flag so that all of this code would not have to be replicated in two scripts just for a single command flag change.code -r dir/
code -n dir/
that is all that is really changing between the scrips so if I could have script-1 import a method from base.js and just pass openInBranch(true) or openInbranch(false) or something to that effect as to whether to open in a new window would be beneficial.
Beta Was this translation helpful? Give feedback.
All reactions