@jtff/slots-protector
Version:
protect all human slots with individual password and give a folder with all the passwords by coalitions
33 lines (23 loc) • 825 B
JavaScript
// post-install.js
/**
* Script to run after npm install
*
* Copy selected files to user's directory
*/
const gentlyCopy = require('gently-copy');
const fs = require('fs');
const filesToCopy = ['protect.js'];
const userPath = process.env.INIT_CWD || '.';
// Moving files to user's local directory
gentlyCopy(filesToCopy, userPath);
const pkgJsonPath = require.main.paths[0].split('node_modules')[0] + 'package.json';
if (!fs.existsSync(pkgJsonPath)) {
fs.writeFileSync(pkgJsonPath, JSON.stringify({}, null, 2));
}
const npm_current_package = require(pkgJsonPath);
if (!npm_current_package.hasOwnProperty('scripts')) {
npm_current_package.scripts = {};
}
npm_current_package.scripts['protect'] = "node protect.js";
fs.writeFileSync(pkgJsonPath, JSON.stringify(npm_current_package, null, 2));