Force create existing folder with Meteor - meteor

When I use the command:
meteor create myfolder
It won't by default allow meteor to install itself if the folder is already existing. I can't find an option to force it. Is it really necessary that Meteor creates the directory by itself first or is this just because of 'good practice'?
I want to automate the creation of a folder first and run the meteor command afterwards, hence the question.

Maybe you want a shell script like the following:
$DIR = <some variable>
if [ ! -f "$DIR" ]; then
meteor create tempDir
mv tempDir/* "$DIR/"
rmdir tempDir
fi
which will copy the contents into your new directory, as long as it doesn't contain any Meteor files already.

Related

Recursively copy the *contents* of a directory

Using any of the standard Robot libraries, is it possible to recursively copy the contents of a directory to an existing destination directory?
Basically, I'm looking for the equivalent of the following shell command: cp -r foo/. bar (note the trailing dot)
I tried Copy Directory but this creates a directory foo inside bar (as documented) and it doesn't stop doing that even when supplying the trailing dot. Copy Files chokes when it encounters a directory.
Is there anything I overlooked? Or do I need to just call cp -r myself?
As I only need this to work on Linux, I ended up implementing a custom keyword calling cp -r. If this is ever needed cross-platform, then I'll follow the suggestions to directly implement it in Python.
Copy Directory Contents
[Documentation] Recursively copies the contents of the source directory into the destination.
[Arguments] ${source} ${destination}
Directory Should Exist ${source}
Directory Should Exist ${destination}
${result} = Run Process cp -r ${source}/. ${destination}/
Should Be Equal As Integers ${result.rc} 0

Add new directory within subdirectory using CVS

How does one add a new directory within a subdirectory using a CVS repository?
cvs add [new_dir_name]
simply creates a new directory on the first level of the repository, while going into the subdirecory I am interested in and adding does not work. i.e.L
cd repository/directory
cvs add [new_dir_name]
Produces an error:
cvs [add aborted]: there is no version here; do 'cvs checkout' first
(This error message, though, still happens when I check out the repository).
Any ideas how to do this?
cd repository
mkdir a
mkdir a/b
mdkdir a/b/c
cvs update -d a/b/c ( not sure if in one go works, if not, try one after another)
The option -d will create directories that are missing. The same should work for add, if you cvs update afterwards and commit to persist it.
Personally I would use git or svn - changed from cvs ~10y ago
You must add each directory in the path to the final subdirectory that is not present on the server in descending oder.
For example...
If you are in the root of your cvs repository, the following should work.
mkdir -p dirname/subdirname
cvs add dirname
cvs add dirname/subdirname
alternately / equivalently
mkdir -p dirname/subdirname
cvs add dirname
cd dirname
cvs add subdirname

Symlink dotfiles

I am having trouble symlinking dotfiles. I have a folder in my home directory ~/dotfiles which I have synced to a github repo. I am trying to take my .vimrc file in ~/dotfiles/.vimrc and create a symbolic link to put it at ~/.vimrc. To do this I type in
ln -s ~/dotfiles/.vimrc ~/.vimrc
But when I run that it says
ln: /Users/me/.vimrc: File exists
What am I doing wrong?
That error message means that you already have a file at ~/.vimrc, which ln is refusing to overwrite. Either delete the ~/.vimrc and run ln again or let ln delete it for you by passing the -f option:
ln -s -f ~/dotfiles/.vimrc ~/.vimrc
There is a better solution for managing dotfiles without using symlinks or any other tool, just a git repo initialized with --bare.
A bare repository is special in a way that they omit working directory, so you can create your repo anywhere and set the --work-tree=$HOME then you don't need to do any work to maintain it.
Approach
first thing to do is, create a bare repo
git init --bare $HOME/.dotfiles
To use this bare repo, you need to specify --git-dir=$HOME/.dotfiles/ and --work-tree=$HOME, better is to create an alias
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME
At this point, all your configuration files are being tracked, and you can easily use the newly registered dotfiles command to manage the repository, ex :-
# to check the status of the tracked and untracked files
dotfiles status
# to add a file
dotfiles commit .tmux.conf -m ".tmux.conf added"
# push new files or changes to the github
dotfiles push origin main
I also use this way to sync and store my dotfiles, see my dotfiles repository and can read at Storing dotfiles with Git where I wrote about managing for multiple devices.
How to symlink all dotfiles in a directory recursively
Have a dotfiles directory that is structured as to how they should be structured at $HOME
dotfiles_home=~/dotfiles/home # for example
cp -rsf "$dotfiles_home"/. ~
-r: Recursive, create the necessary directory for each file
-s: Create symlinks instead of copying
-f: Overwrite existing files (previously created symlinks, default .bashrc, etc)
/.: Make sure cp "copy" the contents of home instead of the home directory itself.
Tips
Just like ln, if you want no headache or drama, use an absolute path for the first argument like the example above.
Note
This only works with GNU cp (preinstalled in Ubuntu), not POSIX cp. Check your man cp, you can install GNU coreutils if needed.
Thanks
To this and this.

How can I save the path to a frequently used directory in UNIX?

Is there a way to save the path to a frequently used directory in UNIX, so instead of having to manually cd /path/to/directory I can just enter a shortcut cd myFavoritePath ??
Define your favorite directories in CDPATH environment variable. It's a colon-separated list of search paths available to the cd command. You should specify not a directory you want to switch but parent directory.
Here is brief info about it: http://docstore.mik.ua/orelly/unix/upt/ch14_05.htm
For example you have three directories you work with frequently:
/home/user/scripts/favorite/
/var/log/
/var/lib/
add to your ~/.bash_profile (or another shell profile file you use) the next line:
export CDPATH=.:/home/user/scripts:/var
In the example below I just redefine CDPATH in shell for the current session
[user#server lib]$ CDPATH=.:/var:/home/user/scripts
[user#server lib]$ cd log
/var/log
[user#server log]$ cd lib
/var/lib
[user#server lib]$ cd favorite
/home/user/scripts/favorite
If you want use tab while execute cd you can install bash-completion http://bash-completion.alioth.debian.org/ but it's optional
Also do not forget cd - command for quick switching to previous working dir
You can always add the directory path in ~/.bashrc
vi ~/.bashrc
export FAV_DIR1=''
The variables in .bashrc load into the environment on new session. So make sure to reboot.
Then you can visit the directory by something like:
cd $FAV_DIR1

Create a File with Touch on a specific Directory

I want a create a file with a specific extension(.done). I am using the command touch. Something Like:
touch `basename $UNZIPFILE`".done"
It's creating the file but in current directory. I want to create this file in a specific directory. Is there a option to provide the directory ?
I checked : http://ss64.com/bash/touch.html , but could not figure out.
I can think of one option is before this command I can do a cd requiredDIR
Is there any other way, I can specify the Directory on the same command, so that I dont have to change the Directory?
Simply prepend the directory variable to the file you are touching.
touch "$MYDIR/$(basename $UNZIPFILE).done"
If the directory doesn't exist, you need to create it.
mkdir -p "$MYDIR" && touch "$MYDIR/$(basename $UNZIPFILE).done"
(It's also better to use $(command) syntax instead of backticks for command substitution.)

Resources