diff --git a/package.json b/package.json index ee5d3fab..2b2a94b3 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "start": "node scripts/prepareSpec.js" }, "devDependencies": { - "shelljs": "^0.8.3" + "cross-spawn": "^6.0.5", + "fs-extra": "^7.0.1" } } diff --git a/scripts/prepareSpec.js b/scripts/prepareSpec.js index 92b30f3a..0d5b9093 100644 --- a/scripts/prepareSpec.js +++ b/scripts/prepareSpec.js @@ -1,11 +1,40 @@ -require('shelljs/global'); +const path = require('path'); -rm('-rf', 'spec/myplugin'); -rm('-rf', 'spec/plugins'); -rm('-rf', 'spec/platforms'); -mkdir('spec/myplugin') -cp('-R', 'package.json', 'plugin.xml', 'scripts', 'src', 'www', 'spec/myplugin'); +const fs = require('fs-extra'); -cd('spec'); +const spawn = require('cross-spawn'); -exec('cordova plugin add myplugin'); +console.info('Removing any old artifacts from spec'); + +fs.removeSync('spec/myplugin'); +fs.removeSync('spec/plugins'); +fs.removeSync('spec/platforms'); + +const myplugin = path.join('spec', 'myplugin'); + +console.info('Copying plugin artifacts into ' + myplugin); + +fs.ensureDirSync(myplugin); + +['package.json', 'plugin.xml'].forEach((src) => { + const dest = path.join(myplugin, src); + fs.copySync(src, dest); +}); + +['scripts', 'src', 'www'].forEach((src) => { + const dest = path.join(myplugin, src); + fs.ensureDirSync(dest); + fs.copySync(src, dest); +}); + +const args = 'plugin add myplugin'; + +console.log('Spawning Cordova CLI in `spec` with the following arguments: ' + args); + +spawn.sync('cordova', args.split(' '), { + cwd: 'spec', + stdio: 'inherit', +}); + +console.info('The spec is now ready to test a copy of this plugin.'); +console.info('Please do `cd spec` and then use `cordova platform add` to add each desired platform.');