Skip to content

Commit

Permalink
fs-extra & cross-spawn in scripts/prepareSpec.js
Browse files Browse the repository at this point in the history
instead of shelljs
  • Loading branch information
Christopher J. Brody committed Mar 13, 2019
1 parent f85c50f commit 699b946
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 9 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"start": "node scripts/prepareSpec.js"
},
"devDependencies": {
"shelljs": "^0.8.3"
"cross-spawn": "^6.0.5",
"fs-extra": "^7.0.1"
}
}
45 changes: 37 additions & 8 deletions scripts/prepareSpec.js
Original file line number Diff line number Diff line change
@@ -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.');

0 comments on commit 699b946

Please sign in to comment.