File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -159,18 +159,7 @@ Returns a boolean or throws on error.
159159
160160## Graceful exit
161161
162- ` proper-lockfile ` automatically remove locks if the process exists. Though, ` SIGINT ` and ` SIGTERM ` signals
163- are handled differently by ` nodejs ` in the sense that they do not fire a ` exit ` event on the ` process ` .
164- To avoid this common issue that ` CLI ` developers have, please do the following:
165-
166-
167- ``` js
168- // Map SIGINT & SIGTERM to process exit
169- // so that lockfile removes the lockfile automatically
170- process
171- .once (' SIGINT' , () => process .exit (1 ))
172- .once (' SIGTERM' , () => process .exit (1 ));
173- ```
162+ ` proper-lockfile ` automatically remove locks if the process exists.
174163
175164
176165## Tests
Original file line number Diff line number Diff line change 33const path = require ( 'path' ) ;
44const fs = require ( 'graceful-fs' ) ;
55const retry = require ( 'retry' ) ;
6+ const onExit = require ( 'signal-exit' ) ;
67
78const locks = { } ;
89
@@ -292,7 +293,7 @@ function getLocks() {
292293
293294// Remove acquired locks on exit
294295/* istanbul ignore next */
295- process . on ( 'exit' , ( ) => {
296+ onExit ( ( ) => {
296297 for ( const file in locks ) {
297298 try { locks [ file ] . options . fs . rmdirSync ( getLockFile ( file ) ) ; } catch ( e ) { /* Empty */ }
298299 }
You can’t perform that action at this time.
0 commit comments