Skip to content

Commit

Permalink
Docs(README): new feature instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
binury committed Apr 15, 2024
1 parent efb3266 commit 4fdc392
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ success!

# Convenient
❯ my-script
zsh: command not found: my-script
pjshell: falling back to npm-script: my-script

> @pjshell/[email protected] my-script
Expand All @@ -21,13 +20,13 @@ success!
❯ lint:style
pjshell: falling back to npm-script: lint:style

# Supports passing args
❯ lint -- --format json
# Supports passing args naturally
❯ lint --format json
pjshell: falling back to npm-script: lint

```

This zsh plugin is for users who want to use pjshell globally on projects they do not own or without having to [use the pjshell package to persistently link a project's scripts](#to-do).
This zsh plugin is for users who want to use pjshell globally on projects they do not own or without having to [use the pjshell package to persistently link a project's scripts](#to-do).[^0]

## Requirements

Expand All @@ -36,6 +35,8 @@ and must be installed. I might remove this requirement later…

## Installation

For either method, the relative path to the temporary `.pjs` directory should be included in your $PATH (as early as possible). E.g.: `export -U PATH=./.pjs${PATH:+:$PATH}`

### [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh/wiki/Customization#adding-a-new-plugin)

```sh
Expand All @@ -58,7 +59,9 @@ popd;

## To-do

- [x] Suppress command-not-found error message if script matches
- [ ] use pjshell to link the scripts per-project
- [ ] Options for handling namespace conflicts (e.g., `test`)
- [ ] Facilitate installation through `npm i -g @pjshell/zsh`
- [ ] use pjshell to link the scripts per-project
- [x] Suppress command-not-found error message if script matches

[^0]: This plugin will create an emphemeral `.pjs` directory containing your scripts as executable files whenever you run a (non-existent) command that matches one of the scripts in the working directory's package.json. As soon as the command runs, the directory is torn down and removed.
1 change: 0 additions & 1 deletion pjshell.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ function _pjshell {
pjs_dir="./.pjs"; local_pjs_dir="$pjs_dir:A"
[[ -d "$local_pjs_dir" ]] || mkdir "$local_pjs_dir"
exec_path="$local_pjs_dir/$cmd"
# TODO: This method of passing ARGV to npm-run is a regression of our easy flag passing feature
[[ -f "$exec_path" ]] || echo "rm -rf $pjs_dir; npm run $cmd -- \$@" > "$exec_path"
chmod +x "$exec_path" # It may not be possible to chmod depending on security settings :\
export -U PATH=$pjs_dir${PATH:+:$PATH} # TODO: Verify export always possible?
Expand Down

0 comments on commit 4fdc392

Please sign in to comment.