V
V
vasIvas2015-03-04 22:58:41
cmd/bat
vasIvas, 2015-03-04 22:58:41

How to add path part to .cmd?

I have windows 8 with nodejs installed globally.
At D:\projs\current_proj\node_modules\.bin\ there are
two files sails.cmd and sails -

@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe"  "%~dp0\..\sails\bin\sails.js" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node  "%~dp0\..\sails\bin\sails.js" %*
)

#!/bin/sh
basedir=`dirname "$0"`

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
  "$basedir/node"  "$basedir/../sails/bin/sails.js" "[email protected]"
  ret=$?
else 
  node  "$basedir/../sails/bin/sails.js" "[email protected]"
  ret=$?
fi
exit $ret

Sails is a server that should be installed globally,
but I consider it local, since its address is
D:\projs\current_proj\node_modules\sails\.....
In order for me to manage all nodejs modules, I have
to launch the console from folders D:\projs\current_proj\node_modules\.bin\
and everything worked and suited me until the appearance of a server that
generates files via the console. But it generates them in the folder from
which I launch the console, but I need two directories
above and one deep. And to do this, I have to go
to the folder I need and write in the console
D:\projs\current_proj\server> D:\projs\current_proj\node_modules\.bin\sails generate ...

And in order to do all this, I have to hold two consoles, and this is a
little annoying. Therefore, I ask those who understand the languages
​​\u200b\u200bthat I showed to help by telling where to add the path
there so that it works the way I need.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OvLab, 2015-03-05
@vasIvas

Maybe I did not quite understand the question, but what prevents you from prescribing all the paths hard?
UPD:
Well, something like this: "% ~ dp0" is the path from where the cmd file is launched. The first two commands set the current folder - where the files will be generated, and then change "% ~ dp0" to its constant value.

@D:
@CD "D:\projs\current_proj\server"
@IF EXIST "D:\projs\current_proj\node_modules\.bin\node.exe" (
  "D:\projs\current_proj\node_modules\.bin\node.exe"  "D:\projs\current_proj\node_modules\sails\bin\sails.js" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node  "D:\projs\current_proj\node_modules\sails\bin\sails.js" %*
)
@CD "D:\projs\current_proj\node_modules\.bin"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question