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

Cordova /hooks directory is deprecated, update to newer format #98

Open
FranciscoG opened this issue Jul 19, 2017 · 1 comment
Open

Comments

@FranciscoG
Copy link

FranciscoG commented Jul 19, 2017

Cordova Hooks documentation shows using the /hooks directory is deprecated. Suggest updating your documentation to use newer hook scripts format.

This worked for me. It's probably not perfect but for now it works

I created a hook_scripts folder. Then in my config.xml I have this:

<hook src="hook_scripts/after_prepare.js" type="after_prepare" />
#!/usr/bin/env node
const spawnSync = require('child_process').spawnSync;

var options = {
  cwd: process.cwd(),
  encoding : 'utf8'
};

var icon = spawnSync('cordova-icon', ['--icon=res/icon.png'], options);

if (icon.stderr) {
  console.log(icon.stderr.toString());
}

console.log(icon.stdout.toString());
@kw-pr
Copy link

kw-pr commented Jan 17, 2018

That is nice. With windows you need to call cordova-icon.cmd so I made some changes to your code:

#!/usr/bin/env node
const spawnSync = require('child_process').spawnSync;

var options = {
  cwd: process.cwd(),
  encoding : 'utf8'
};

const os = require('os');
var cmdSuffix = (os.platform() === 'win32' ? '.cmd' : '');
var icon = spawnSync('cordova-icon' + cmdSuffix, ['--icon=res/icon.png'], options);

if (icon.stderr) {
  console.log(icon.stderr.toString());
}

console.log(icon.stdout.toString());

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants