Skip to content

Commit 4f7f4e0

Browse files
authored
Merge pull request #206 from nguymin4/improve-doc
Add instruction for NodeJS related project and tools
2 parents 3a31bfb + 75ecae9 commit 4f7f4e0

File tree

1 file changed

+73
-2
lines changed

1 file changed

+73
-2
lines changed

docs/restoring_programs.md

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Restoring programs
2+
- [General instructions](#general-instructions)
3+
- [Clarifications](#clarifications)
4+
- [Working with NodeJS](#nodejs)
25

6+
### General instructions <a name="general-instructions"></a>
37
Only a conservative list of programs is restored by default:<br/>
48
`vi vim nvim emacs man less more tail top htop irssi mutt`.
59

@@ -31,7 +35,7 @@ contains space-separated list of additional programs to restore.
3135

3236
set -g @resurrect-processes ':all:'
3337

34-
### Clarifications
38+
### Clarifications <a name="clarfications"></a>
3539

3640
> I don't understand tilde `~`, what is it and why is it used when restoring
3741
programs?
@@ -73,7 +77,7 @@ the command line.
7377
Naturally, you'd rather want to see just `rails server` (what you initially
7478
typed), but that information is now unfortunately lost.
7579

76-
To aid this, you can use arrow `->`:
80+
To aid this, you can use arrow `->`: (**note**: there is no space before and after `->`)
7781

7882
set -g @resurrect-processes '"~rails server->rails server"' # OK
7983

@@ -98,3 +102,70 @@ Here's the general workflow for figuring this out:
98102
file.
99103
- Now that you know the full and the desired process string use tilde `~` and
100104
arrow `->` in `.tmux.conf` to make things work.
105+
106+
### Working with NodeJS <a name="nodejs"></a>
107+
If you are working with NodeJS, you may get some troubles with configuring restoring programs.
108+
109+
Particularly, some programs like `gulp`, `grunt` or `npm` are not saved with parameters so tmux-resurrect cannot restore it. This is actually **not tmux-resurrect's issue** but more likely, those programs' issues. For example if you run `gulp watch` or `npm start` and then try to look at `ps` or `pgrep`, you will only see `gulp` or `npm`.
110+
111+
To deal with these issues, one solution is to use [yarn](https://yarnpkg.com/en/docs/install) which a package manager for NodeJS and an alternative for `npm`. It's nearly identical to `npm` and very easy to use. Therefore you don't have to do any migration, you can simply use it immediately. For example:
112+
- `npm test` is equivalent to `yarn test`,
113+
- `npm run watch:dev` is equivalent to `yarn watch:dev`
114+
- more interestingly, `gulp watch:dev` is equivalent to `yarn gulp watch:dev`
115+
116+
Before continuing, please ensure that you understand the [clarifications](#clarifications) section about `~` and `->`
117+
118+
#### yarn
119+
It's fairly straight forward if you have been using `yarn` already.
120+
121+
set -g @resurrect-processes '"~yarn watch"'
122+
set -g @resurrect-processes '"~yarn watch->yarn watch"'
123+
124+
125+
#### npm
126+
Instead of
127+
128+
set -g @resurrect-processes '"~npm run watch"' # will NOT work
129+
130+
we use
131+
132+
set -g @resurrect-processes '"~yarn watch"' # OK
133+
134+
135+
#### gulp
136+
Instead of
137+
138+
set -g @resurrect-processes '"~gulp test"' # will NOT work
139+
140+
we use
141+
142+
set -g @resurrect-processes '"~yarn gulp test"' # OK
143+
144+
145+
#### nvm
146+
If you use `nvm` in your project, here is how you could config tmux-resurrect:
147+
148+
set -g @resurrect-processes '"~yarn gulp test->nvm use && gulp test"'
149+
150+
#### Another problem
151+
Let take a look at this example
152+
153+
set -g @resurrect-processes '\
154+
"~yarn gulp test->gulp test" \
155+
"~yarn gulp test-it->gulp test-it" \
156+
'
157+
**This will not work properly**, only `gulp test` is run, although you can see the command `node /path/to/yarn gulp test-it` is added correctly in `.tmux/resurrect/last` file.
158+
159+
The reason is when restoring program, the **command part after the dash `-` is ignored** so instead of command `gulp test-it`, the command `gulp test` which will be run.
160+
161+
A work around, for this problem until it's fixed, is:
162+
- the config should be like this:
163+
164+
set -g @resurrect-processes '\
165+
"~yarn gulp test->gulp test" \
166+
"~yarn gulp \"test-it\"->gulp test-it" \
167+
168+
- and in `.tmux/resurrect/last`, we should add quote to `test-it` word
169+
170+
... node:node /path/to/yarn gulp "test-it"
171+

0 commit comments

Comments
 (0)