Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing error on npm run ios-sim & npm run android-sim #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jasonmadigan
Copy link

Fixing a small error when running the iOS/Android simulator via npm run ios-sim.

Previous error:

> npm run compile && cordova platform add ios ; && cordova run ios --emulator

sh: -c: line 0: syntax error near unexpected token `&&'
sh: -c: line 0: `npm run compile && cordova platform add ios ; && cordova run ios --emulator'

@jasonmadigan
Copy link
Author

@evanshortiss FYI

@@ -11,8 +11,8 @@
"compile": "tsc && npm run bundle-js && npm run vendor-js",
"bundle-js": "browserify -e src/index.js -o www/bundle.js --no-bundle-external --debug",
"vendor-js": "browserify -o www/vendor.js -r fh-js-sdk -r fastclick -r react-dom -r react",
"ios-sim": "npm run compile && cordova platform add ios ; && cordova run ios --emulator",
Copy link
Owner

@evanshortiss evanshortiss Jun 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

D'oh, my bad! One thing to note is that the ; was deliberate, I just forgot to remove the && on the ios-sim line.

The reason for this is that if the platform is already added Cordova returns an error exit code on add. The ; bypasses this since we just wanted to ensure the platform existed. Check this output:

> ts-react-hello-world@0.1.0 vendor-js workspaces/ts-react-hello-world
> browserify -o www/vendor.js -r fh-js-sdk -r fastclick -r react-dom -r react

Error: Platform ios already added.
Building project: workspaces/ts-react-hello-world/platforms/ios/RHMAP Hello World using TypeScript and React.xcworkspace
	Configuration: Debug
	Platform: emulator

If we use && after the cordova platform add ios it works fine initially, but any future calls will fail with Error: Platform ios already added.. The ; bypasses this.

What are your thoughts on a potnetial alternative for improving this?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"ios-sim": "npm run compile && cordova platform add ios ; && cordova run ios --emulator",
"android-sim": "npm run compile && cordova platform add android ; cordova run android --emulator"
"ios-sim": "npm run compile && cordova platform add ios && cordova run ios --emulator",
"android-sim": "npm run compile && cordova platform add android cordova run android --emulator"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd need either ; or && here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants