What is is-npm?
The 'is-npm' package is a simple utility that allows developers to check if their code is running in an npm script environment. This can be particularly useful for adjusting the behavior of scripts based on the environment they are executed in, such as enabling certain features only when run through npm.
Check if running in npm script
This code checks if the current script is executed through npm. If 'isNpm' is true, it logs that the script is running via npm; otherwise, it logs that it is not.
const isNpm = require('is-npm');
if (isNpm) {
console.log('Running via npm!');
} else {
console.log('Not running via npm.');
}