按照官方的說明下載源碼,安裝依賴庫,具體可從這來:
https://github.com/appium/appium/blob/master/docs/en/contributing-to-appium/appium-from-source.md
基本上只要三條命令就可以了:
git clone https://github.com/appium/appium.git cd appium npm install gulp transpile node .
這樣就可以起起來appium server:
這時修改了appium/node_modules/appium-base-driver/lib/mjsonwp/mjsonwp.js 里的路由部分,加入一條console.log語句:
要想生效,需要在appium/node_modules/appium-base_driver目錄下運行:
gulp transpile
會生成build目錄,這才可以生效。
想到在最外層的appium目錄下的gulpfile.js中定義一個可以重新編譯的task:
// rebuild所有gulpfile.js var exec = require('child_process').exec gulp.task('rebuildAll', function () { // 當前build exec('gulp transpile', function (err, stdout, stderr) { exec('gulp transpile', function (err, stdout, stderr) { console.log(__dirname + 'build done') }) }) fs.readdirSync(path.join(__dirname, 'node_modules')).forEach(function (dir) { var modulePath = path.join(__dirname, 'node_modules', dir) if(fs.existsSync(path.join(modulePath, 'gulpfile.js'))) { exec('gulp transpile', {cwd: modulePath}, function (err, stdout, stderr) { console.log(modulePath + ' build done') }) } }) })
對gulp不太熟,寫的有點糙,可以只編譯改動的部分,但這里一律重編譯.
這樣,在WebStorm,只要跑這個gulpfile.js里的rebuildAll就可以讓修改的代碼生效了.