Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure compatibility with NPM 7 and 8 #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ npm install node-native-printer --save
You will be prompted for selecting edge backend based on installed packages that contains the word "edge". If you wish to enter manually the name of edge backend package, select `Not listed` and type it manually.

#### Flags (Windows only)
* `-p` or `--production`: to be used when packaging with (i.e.) electron-builder. It will skip prompting for edge backend and will take correctly the dll path needed for windows.<br>
**Note** that `-p` flag require that edge backend has been specified during installation.
* `--production` or `NODE_ENV=production`: to be used when packaging with (i.e.) electron-builder. It will skip prompting for edge backend and will take correctly the dll path needed for windows.<br>
**Note** that `--production` flag require that edge backend has been specified during installation.

## Usage
First of all you need to require the module inside your app this way:
Expand Down
13 changes: 5 additions & 8 deletions install/install_win.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@ const dotenv = require('dotenv');

module.exports = function(){

var args = JSON.parse(process.env.npm_config_argv).original;
var test = new RegExp('^-.*$', 'g');
var env = process.env.NODE_ENV || 'development';

var flags = args.filter(function(value) {
return test.test(value);
});

if (flags.includes('-p') || flags.includes('--production')) {
if (env === 'production') {
dotenv.config({path: fs.realpathSync(__dirname + '/../.env')});
if (process.env.NNP_PACKAGE) {
return;
} else {
console.error('It has been used flag -p but no package has been specified during dev installation.\nAborting.');
console.error('Installation with NODE_ENV=production requested, but NNP_PACKAGE is not set.');
console.error('You can set NNP_PACKAGE during dev installation or in your .env file.');
console.error('Aborting.');
process.exit(1);
}
}
Expand Down
338 changes: 337 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.