'use strict';

const NO_GLOBAL_INSTALL_MESSAGE = `
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! Starting from v2.0.0 publish-please can't be installed globally.          !!
!! Use local installation instead : 'npm install --save-dev publish-please', !!
!! Or use npx if you do not want to install publish-please as a dependency.  !!
!! (learn more: https://github.com/inikulin/publish-please#readme).          !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
`;

module.exports = function preventGlobalInstall() {
    const getNpmArgs = require('./utils/get-npm-args');
    const npmArgs = getNpmArgs(process.env);
    if (npmArgs.npx) {
        return;
    }
    if (npmArgs['--global']) {
        reportNoGlobalInstall();
        process.exit(1);
    }
};

function reportNoGlobalInstall() {
    try {
        const chalk = require('chalk');
        console.log(chalk.bgRed(NO_GLOBAL_INSTALL_MESSAGE));
    } catch (error) {
        console.log(NO_GLOBAL_INSTALL_MESSAGE);
    }
}

@@ -8,16 +8,65 @@
 rict';%0A%0A
+const reporter = require('./reporters/current');%0A
 const NO
@@ -916,156 +916,38 @@
     
-try %7B%0A        const chalk = require('chalk');%0A        console.log(chalk.bgRed(NO_GLOBAL_INSTALL_MESSAGE));%0A    %7D catch (error) %7B%0A        console.log
+reporter.current().reportError
 (NO_
@@ -971,16 +971,10 @@
 SSAGE);%0A
-    %7D%0A
 %7D%0A

use reporter in prevent-global-install.js