Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Commit

Permalink
fix: UnhandledPromiseRejectionWarning: TypeError: execa.shellSync is …
Browse files Browse the repository at this point in the history
…not a function #95
  • Loading branch information
rstoenescu committed Nov 4, 2019
1 parent 2c16655 commit b8e8b0a
Show file tree
Hide file tree
Showing 4 changed files with 1,259 additions and 1,295 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
},
"dependencies": {
"elementtree": "^0.1.7",
"execa": "^2.0.4",
"fs-extra": "^8.1.0",
"imagemin": "^7.0.0",
"imagemin-optipng": "^7.0.0",
Expand Down
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { join } = require('path')
const { spawnSync } = require('./utils/spawn.js')
const icongenie = require('../lib/index.js')
const execa = require('execa')
const settings = require('../lib/settings')
const { copySync, existsSync, readFileSync, writeFileSync } = require('fs-extra')
const { validatePng, computeHash, validateHexRGB } = require('./utils')
Expand Down Expand Up @@ -62,7 +62,13 @@ Splashscreens for Cordova requires a Cordova plugin
Attempting to install it...
`)

execa.shellSync(`cd ${api.resolve.cordova('.')} && cordova plugin add cordova-plugin-splashscreen`)
spawnSync('cordova', [ 'plugin', 'add', 'cordova-plugin-splashscreen' ], {
cwd: api.resolve.cordova('.')
}, () => {
console.log()
console.error('Failed to install cordova-plugin-splashscreen. Please do it manually.')
console.log()
})

if (!plugins.find(node => node.attrib.name === 'cordova-plugin-splashscreen')) {
// add the splashscreen but get the right version installed
Expand Down
20 changes: 20 additions & 0 deletions src/utils/spawn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const crossSpawn = require('cross-spawn')

module.exports.spawnSync = function (cmd, params, opts, onFail) {
console.log(`[sync] Running "${cmd} ${params.join(' ')}"\n`)

const runner = crossSpawn.sync(
cmd,
params,
{ stdio: 'inherit', stdout: 'inherit', stderr: 'inherit', ...opts }
)

if (runner.status || runner.error) {
console.log()
console.error(`⚠️ Command "${cmd}" failed with exit code: ${runner.status}`)
if (runner.status === null) {
console.error(`⚠️ Please globally install "${cmd}"`)
}
onFail && onFail()
}
}
Loading

0 comments on commit b8e8b0a

Please sign in to comment.