How to use a different cocos2d-js source location using 'cocos' cmd

I need to modify the javascript for the core cocos2d game engine, but the ‘cocos run -p web’ command does not use the cocos2d-js engine source in my game project folder. Instead is uses the cocos2d-js engine source from the ‘sdk’ dir:

I have 2 locations where the javascript source for the cocos2d-js engine is:

  1. in my ‘sdk’ folder, where the ‘cocos’ cmd tool is (sdk\cocos2d-x\web)
  2. in my ‘game’ project folder (myGame\frameworks\cocos2d-html5).

I want to use the source in the ‘game’ folder, so I can store it to repository, so I won’ have to modify the ‘sdk’ folder source.

Is it possible to tell the ‘cocos’ tool to use the engine source in the game directory where I run it (cocos run -p web)?

you can run cocos run --help and check out the options.

But you can always set the env var before running cocos run, then set it back when the command is done back to the original location. Use a script to do this.

1 Like