-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fs-extra & cross-spawn in scripts/prepareSpec.js
instead of shelljs
- Loading branch information
Christopher J. Brody
committed
Mar 13, 2019
1 parent
f85c50f
commit 699b946
Showing
2 changed files
with
39 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.'); |