dpa99c / cordova-diagnostic-plugin

Cordova/Phonegap plugin to manage device settings
539 stars 361 forks source link

Post-install hook might fail on some versions of NPM #471

Open peitschie opened 2 years ago

peitschie commented 2 years ago

Not a bug here really... but...

Due to an upstream NPM bug (since fixed) https://github.com/npm/cli/issues/1905, there's a raft of NPM versions that don't correctly execute the post-install hook required by this plugin to strip the extraneous permissions and features out.

As a workaround, I've added a hook to my project in hooks/before_plugin_install.js with the following content:

const process = require('process');
const path = require('path');

const cwd = process.cwd();
try {
  process.chdir("node_modules/cordova.plugins.diagnostic")
  require(path.resolve("./scripts/apply-modules.js"));
} finally {
  process.chdir(cwd);
}

Just reporting this here in case it's something worth documenting.