allow binaries in vendor folder to be cached

aka: don't delete binaries in node_modules folder, since they shouldn't change anyways (unless the package is also updated)
This commit is contained in:
jake committed 2020-02-18 17:40:51 -05:00
1 parent 434a6865cf
commit 6c87e415dc
10 files changed
+3588 -129

No files matched your search

+5 -26
View File
@@ -1,30 +1,9 @@
'use strict';
const path = require('path');
const bin = require('.');
function getProjectRoot() {
// `projectRoot` on postinstall could be INIT_CWD introduced in npm >= 5.4
// see: https://github.com/npm/npm/issues/16990
const initCwd = process.env.INIT_CWD;
if (initCwd)
return initCwd;
// Fallback of getting INIT_CWD
const cwd = process.cwd();
const paths = cwd.split(path.sep);
// If `process.cwd` ends with 'node_modules/*' then get the dependent root directory,
// otherwise return the `cwd` (ordinary it will be the postinstall process of hugo-bin itself).
if (paths.length > 1 && paths[paths.length - 2] === 'node_modules')
return path.resolve('../../', cwd);
return cwd;
}
bin(getProjectRoot()).run(['version'])
.then(() => {
console.log('✔ Hugo installed successfully!');
})
.catch(error => {
console.error('✖ ERROR: Hugo installation failed. :(\n', error);
});
bin.run(['version']).then(() => {
console.log('✔ Hugo installed successfully!');
}).catch(error => {
console.error('✖ ERROR: Hugo installation failed. :(\n', error);
});