I want to make a script for my angular2 project that renames README.md to README_2.md. I installed "renamer" : "0.6.1" and made this script:
"renameMd": "renamer --find js/README.md --replace js/README_2.md" in package.json, but it doesn't work. It gives me this error: No input files supplied. How can I fix it ?
PS: the file is located in the js folder.
renamer takes a last parameter to filter the files that need to be renamed.
renamer --find README --replace README_2 js/README.md should work.
If you are using Linux, you could also use mv: mv js/README.md js/README_2.md (move in Windows).
Related
I made a change in a shell script to use a version of cmake and can't find this script. I want to use cmake-3.18.5, I have installed it and changed the path to it in bashrc, but it still uses the older version cmake-3.18.2. How to find where this happens?
You're problem appears to be that you put the filename in your path, not the directory.
First, try this at the command line to make sure cmake is installed:
/HOME/cmake-3.18.5/bin/cmake --version
Then if that works, change your path on the command line:
export PATH=/HOME/cmake-3.18.5/bin:$PATH
Note that PATH takes directories, not files or executables.
Now type
type -aP cmake
Make sure the right directory shows up (/HOME/cmake-3.18.5/bin/cmake)
Now put this path command in your .bashrc file and see if it works this time.
Is this even possible? I am trying to script this install of IBM Clearcase and the path to it is like:
../disk1/InstallerImage_linux_gtk.x86/install.xml
The script barfs at the .x86 and it says "No such file or directory."
So I tried to just do vim ../disk1/InstallerImage_linux_gtk.x86/install.xml in a terminal and it opens the .x86 like a folder and allows you to select a file to edit instead of opening it directly.
Is there a way around this? Would the only way be to rename the folder before, do the sed voodoo and then move it back with the . in the name?
I guess I missed the obvious. I guess I could cd to the directory first and then do sed -i '' install.xml.
More info:
RHEL 6.5
Bash Script
You need to script a silent ClearCase installation, using one of the sample response files for Rational ClearCase.
That would avoid the need to open any file in vim.
See "Installing silently", which involves the following steps:
Run a silent install of Installation Manager using the Installation Manager installer.
Obtain a copy of the product response file and update it for your environment. If you want to record a response file using Installation Manager, see the Installation Manager information center for instructions.
Run a silent install of the Rational product using the Installation Manager.
I think you have created a file with a seriously strange file name. Do this:
$ cd /path/to/where/you/run/the/script/from
$ file ..
$ file ../disk1
$ file ../disk1/InstallerImage_linux_gtk.x86
$ file ../disk1/InstallerImage_linux_gtk.x86/install.xml
Every component of the relative path (beginning with "..") must be a directory. Only the final line should claim to be an ordinary file.
I use bower and grunt in my workflow, and I wanted to install bower at the same time as grunt and pull down all my bower dependencies. So I created a package.json file that has a script attached on postinstall, which I also pass my github project repo, and dropped my post_install.sh into /root/bin.
{ // snippet of package.json
...
"scripts": {
"postinstall": "bin\\post_install.sh https://github.com/blah/blah.git
},
...
}
so running npm install would run post_install.sh, which runs
#!/bin/bash
node_modules/.bin/bower install
grunt setup
git init
git add .
git commit -m "Initial commit of project artifacts"
git remote add origin $1
git push -u origin master
This only works if I set git bash to open in my project directory. So I've been trying to figure out how to switch directories from where git bash opens at /htdocs to /htdocs/myproject using an alias. I read up on how to set this I thought, but I can't figure out how to invoke this file... incidentally also tried putting it in another .sh file to see if that worked.
#!.bashrc
alias projDir='cd /onloadsolutions'
What am I doing wrong that the alias above in /bin/.bashrc won't execute in my post_install.sh when dropped above "grunt setup"?
Dropping this into post_install.sh
echo "script running has basename `basename $0`, dirname `dirname $0`"
echo "present working directory is `pwd`"
gives a basename of D:/htdocs/onloadsolutions/bin/post_install.sh, but my present working directory is /d/htdocs, which when the bower and git commands run they do it in the wrong directory.
Not 100% sure what you mean but I am guessing when you open bash you want to
be able to type a command to take you to your project
then type npm install and have it pull down all your dependencies
Try editing your .bashrc file (this should be in your home directory, not in the /bin folder) to access this you can use something like
nano ~/.bashrc
(~/ is a shortcut to your home directory)
and look in it for any existing alias commands or add yours down the bottom.
then after opening another bash session (.bashrc only runs when you first start terminal) you should be able to see your current aliases by typing "alias"
you can launch the alias you mentioned above by typeing "projDir" into the console. It would be much better to add the full path in your alias i.e.
alias projDir='cd /var/www/onloadsolutions'
then you can call it from anywhere. Otherwise you might end up in a different folder than you expect.
UPDATE
See comments below.
Put cd $2 in the second to top line of the post_install.sh file and add a second parameter to the package.json file that calls it.
I am a windows developer switching over to OSX. I am very confused though. I am learning node.js and the documentation tells me to add a reference to nodemon at the path...
/usr/local/bin/nodemon
However when I am at the terminal and I type 'ls' I get the following output...
And that doesn't have a /usr/ folder ... And what is even more confusing is that if I do...
ls -a
Then I can see all my hidden folder with a folder in called .npm which seems to have all my modules. In windows this is easy it just installs all npm modules into %AppData%/npm or something but I just don't get it on OSX can somebody enlighten me please?
ls lists the directories and files in your current working directory.
You can find your current working directory with pwd (short for 'print working directory')
You can change your current working directory with the cd (change directory) command. In your case, you could run
cd /usr/local
ls
and it would show you the bin directory. Alternatively, you could directly run
ls /usr/local
As a special extra note, the Terminal Prompt itself actually displays the current working directory (by default). In your case, it shows ~, which is shorthand for the user profile directory, which the Terminal opens to automatically. It is generally /Users/<username>.
This is the way I install the config files:
file(GLOB ConfigFiles ${CMAKE_CURRENT_SOURCE_DIR}/configs/*.xml
${CMAKE_CURRENT_SOURCE_DIR}/configs/*.xsd
${CMAKE_CURRENT_SOURCE_DIR}/configs/*.conf)
install(FILES ${ConfigFiles} DESTINATION ${INSTDIR})
But I need to convert one of the xml files before installing it. There is an executable that can do this job for me:
./Convertor a.xml a-converted.xml
How can I automatically convert the xml file before installing it? It should be a custom command or target that installing depends on it, I just don't know how to make the install command depend on it though. Any advice would be appreciated!
Take a look at the SCRIPT version of install:
The SCRIPT and CODE signature:
install([[SCRIPT <file>] [CODE <code>]] [...])
The SCRIPT form will invoke the given CMake script files during
installation. If the script file name is a relative path it will be
interpreted with respect to the current source directory. The CODE
form will invoke the given CMake code during installation. Code is
specified as a single argument inside a double-quoted string.
For example:
install(CODE "execute_process(\"./Convertor a.xml a-converted.xml\")")
install(FILES a-converted.xml DESTINATION ${INSTDIR})
Be sure to checkout the entry for execute_process in the manual. Also be aware that macro expansion inside the CODE parameter can be a bit tricky to get right. Check the generated cmake_install.cmake in your build directory where the generated code will be placed.
I think that your specific case would work better if you were to use a custom command and target like so:
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/a-converted.xml
COMMAND ./Convertor a.xml a-converted.xml
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/Convertor
)
add_custom_target(run ALL
DEPENDS ${CMAKE_BINARY_DIR}/a-converted.xml
COMMENT "Generating a-converted.xml" VERBATIM
)
install(
FILES ${CMAKE_BINARY_DIR}/a-converted.xml
DESTINATION ${INSTDIR}
)
Note: I don't have all the details, so the directories are probably
not exactly what you'd want in your environment, although it's
a good idea to generate files in the ${CMAKE_BINARY_DIR} area.
That way you can be sure that the file a-converted.xml is built at the time you want to install it. Especially, these two rules make sure that if you make changes to the file, it gets recompiled.