Skip to content

Commit

Permalink
fix running without config file (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
benfc1993 authored Oct 17, 2024
1 parent 7000d18 commit 0168a43
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ jobs:
run: |
yarn
yarn build
npm publish
yarn npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scripts-cli",
"version": "2.1.2",
"version": "2.1.3",
"description": "CLI to run package json scripts and any other scripts in an npm project.",
"main": "./dist/index.js",
"types": "./dist/types.d.ts",
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async function run(options: Record<string, string | boolean | string[]> = {}) {

const npmScripts = Object.keys(data.scripts)
.filter((script) => {
if (!config) return true;
return !config.exclude?.includes(script);
})
.reduce((acc: Options, script) => {
Expand All @@ -35,7 +36,7 @@ async function run(options: Record<string, string | boolean | string[]> = {}) {
try {
const { cmd, args } = await presentOptions({
...npmScripts,
...config.options,
...config?.options,
});
child_process.spawn(cmd + " " + args, { stdio: "inherit", shell: true });
} catch (e) {
Expand Down
1 change: 1 addition & 0 deletions src/presentOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import FuzzySearch from "fuzzy-search";

export async function presentOptions(options: Options) {
const choices = Object.keys(options);

if (choices.length === 0) throw new Error("no options");

const selection = await search<keyof typeof options>({
Expand Down

0 comments on commit 0168a43

Please sign in to comment.