2

how can I run 'cordova prepare ios' from a different folder? Just perhaps from the parent folder of the app i try to build and prepare. Or from a shell script (but cd to folder doesn't work either within a shell script - console works perfectly!)

Build works with this:

/Users/someone/cordova/appname/platforms/ios/cordova/build

But there is no prepare inside the ios/cordova/ folder.

prepare is located @ /usr/local/lib/node_modules/cordova/bin/cordova prepare ios

How can I set a path? --path /Users/someone/cordova/appname/ doesn't work.

Or some other ideas?

Thanks!

****update****

This doesn't work (also pushd, popd):

ssh -l username -o 'HostKeyAlias example.com' example.com "(cd /Users/someone/cordova/appname && /usr/local/lib/node_modules/cordova/bin/cordova prepare ios)"
env: node: No such file or directory

But if I use just ls or pwd I'll get the correct path.

I tried also this:

ssh -l username -o 'HostKeyAlias example.com' example.com <<'ENDSSH'
cd /Users/someone/cordova/appname
cordova prepare
ENDSSH

****solution****

I already got it! (https://stackoverflow.com/a/1472444/2192501)

ssh -l username -o 'HostKeyAlias example.com' example.com "source /etc/profile;cd /Users/someone/cordova/appname;cordova prepare)"
Community
  • 1
  • 1
Xairoo
  • 335
  • 1
  • 9
  • would help if you narrow the focus of your question. Are you trying to write a shell script? Are you trying to execute from a terminal? – Lorenzo Jul 29 '14 at 21:41
  • Yes, that's correct. I have to execute this command from a remote host through ssh. So a single command would be better for me, but no matter if single or try to run a script from remote, this doesn't work. – Xairoo Jul 30 '14 at 07:22

2 Answers2

1

the method to run commands from a different folder in a bash script is 'cd'

you can also look at pushd and popd http://en.wikipedia.org/wiki/Pushd_and_popd

another method to try would be

(cd path/to/cordova/project && cordova prepare ios)

this will spawn a subshell, change the working directory to the cordova project, execute the cordova prepare command, then close. This won't alter the working directory of the shell you execute from.

the prepare file which eventually gets executed is based on the platform arguments, and is downloaded off of your node_modules folder. It is called by the Cordova CLI with the correct arguments, including the path to the cordova project. The Cordova CLI knows where your cordova project is implicitly, because you executed the commands from the project root

Lorenzo
  • 413
  • 2
  • 8
0

I already got it! (https://stackoverflow.com/a/1472444/2192501)

ssh -l username -o 'HostKeyAlias example.com' example.com "source /etc/profile;cd /Users/someone/cordova/appname;cordova prepare)"
Community
  • 1
  • 1
Xairoo
  • 335
  • 1
  • 9