From 38da9b9bb479d3abae6558ba738ec63403ffa2b0 Mon Sep 17 00:00:00 2001 From: slavaGanzin Date: Sun, 24 Jul 2016 13:08:54 +0300 Subject: [PATCH 1/5] async npm with caching --- plugins/npm/npm.plugin.zsh | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 43aedc36d..33c37a9c7 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -43,4 +43,3 @@ alias npmst="npm start" # Run npm test alias npmt="npm test" - From 4c66eedf614cf064b01558602b5b4059ad8e3fde Mon Sep 17 00:00:00 2001 From: slavaGanzin Date: Tue, 27 Sep 2016 14:42:30 +0300 Subject: [PATCH 2/5] npm --- plugins/npm/npm.plugin.zsh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 33c37a9c7..2415546c4 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -1,3 +1,4 @@ +<<<<<<< 38da9b9bb479d3abae6558ba738ec63403ffa2b0 (( $+commands[npm] )) && { __NPM_COMPLETION_FILE="${ZSH_CACHE_DIR}/npm_completion" @@ -10,6 +11,14 @@ unset __NPM_COMPLETION_FILE } +======= +completion=~/.npm_completion +if [ ! -f $completion ]; then + npm completion 2>/dev/null > $completion +fi +source $completion +(rm $completion; npm completion 2>/dev/null > $completion &) +>>>>>>> prevent error on first launch # Install dependencies globally alias npmg="npm i -g " From e711a5042d6e7a5a78460fe20a1e702400458851 Mon Sep 17 00:00:00 2001 From: slavaGanzin Date: Tue, 27 Sep 2016 14:44:37 +0300 Subject: [PATCH 3/5] NPM: new async implementation --- plugins/npm/npm.plugin.zsh | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 2415546c4..1618cb78b 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -1,25 +1,10 @@ -<<<<<<< 38da9b9bb479d3abae6558ba738ec63403ffa2b0 -(( $+commands[npm] )) && { - __NPM_COMPLETION_FILE="${ZSH_CACHE_DIR}/npm_completion" - - if [[ ! -f $__NPM_COMPLETION_FILE ]]; then - npm completion >! $__NPM_COMPLETION_FILE 2>/dev/null - [[ $? -ne 0 ]] && rm -f $__NPM_COMPLETION_FILE - fi - - [[ -f $__NPM_COMPLETION_FILE ]] && source $__NPM_COMPLETION_FILE - - unset __NPM_COMPLETION_FILE -} -======= -completion=~/.npm_completion -if [ ! -f $completion ]; then - npm completion 2>/dev/null > $completion -fi -source $completion -(rm $completion; npm completion 2>/dev/null > $completion &) ->>>>>>> prevent error on first launch - +(( $+commands[npm] )) && +( + COMPLETION="${ZSH_CACHE_DIR}npm_completion" + [[ ! -f $COMPLETION ]] && npm completion 2>/dev/null >! $COMPLETION + source $COMPLETION + npm completion 2>/dev/null >! $COMPLETION & +) # Install dependencies globally alias npmg="npm i -g " From 9d81d049d9145cce7da6f88ab7057ceb5786cf78 Mon Sep 17 00:00:00 2001 From: slavaGanzin Date: Wed, 28 Sep 2016 21:29:05 +0300 Subject: [PATCH 4/5] fix review notices --- plugins/npm/npm.plugin.zsh | 55 ++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 1618cb78b..71eaa2592 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -1,39 +1,42 @@ (( $+commands[npm] )) && -( - COMPLETION="${ZSH_CACHE_DIR}npm_completion" +{ + + COMPLETION="${ZSH_CACHE_DIR}/npm_completion" [[ ! -f $COMPLETION ]] && npm completion 2>/dev/null >! $COMPLETION source $COMPLETION npm completion 2>/dev/null >! $COMPLETION & -) -# Install dependencies globally -alias npmg="npm i -g " + + unset COMPLETION + # Install dependencies globally + alias npmg="npm i -g " -# npm package names are lowercase -# Thus, we've used camelCase for the following aliases: + # npm package names are lowercase + # Thus, we've used camelCase for the following aliases: -# Install and save to dependencies in your package.json -# npms is used by https://www.npmjs.com/package/npms -alias npmS="npm i -S " + # Install and save to dependencies in your package.json + # npms is used by https://www.npmjs.com/package/npms + alias npmS="npm i -S " -# Install and save to dev-dependencies in your package.json -# npmd is used by https://github.com/dominictarr/npmd -alias npmD="npm i -D " + # Install and save to dev-dependencies in your package.json + # npmd is used by https://github.com/dominictarr/npmd + alias npmD="npm i -D " -# Execute command from node_modules folder based on current directory -# i.e npmE gulp -alias npmE='PATH="$(npm bin)":"$PATH"' + # Execute command from node_modules folder based on current directory + # i.e npmE gulp + alias npmE='PATH="$(npm bin)":"$PATH"' -# Check which npm modules are outdated -alias npmO="npm outdated" + # Check which npm modules are outdated + alias npmO="npm outdated" -# Check package versions -alias npmV="npm -v" + # Check package versions + alias npmV="npm -v" -# List packages -alias npmL="npm list" + # List packages + alias npmL="npm list" -# Run npm start -alias npmst="npm start" + # Run npm start + alias npmst="npm start" -# Run npm test -alias npmt="npm test" + # Run npm test + alias npmt="npm test" +} From 96f7c0762f4dd285e5f2f224659ccb3b21275185 Mon Sep 17 00:00:00 2001 From: slavaGanzin Date: Thu, 29 Sep 2016 13:08:23 +0300 Subject: [PATCH 5/5] fix run twice --- plugins/npm/npm.plugin.zsh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh index 71eaa2592..3961af8b0 100644 --- a/plugins/npm/npm.plugin.zsh +++ b/plugins/npm/npm.plugin.zsh @@ -2,11 +2,17 @@ { COMPLETION="${ZSH_CACHE_DIR}/npm_completion" - [[ ! -f $COMPLETION ]] && npm completion 2>/dev/null >! $COMPLETION - source $COMPLETION - npm completion 2>/dev/null >! $COMPLETION & - + + if [[ ! -f $COMPLETION ]]; then + npm completion 2>/dev/null >! $COMPLETION + source $COMPLETION + else + source $COMPLETION + npm completion 2>/dev/null >! $COMPLETION & + fi + unset COMPLETION + # Install dependencies globally alias npmg="npm i -g "