mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-19 21:57:51 +00:00
Workaround balena-dev/oclif compatibility issues
Change-type: patch Signed-off-by: Scott Lowe <scott@balena.io>
This commit is contained in:
parent
8a808e25d0
commit
c85acbd90b
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// ****************************************************************************
|
||||
// THIS IS FOR DEV PERROSES ONLY AND WILL NOT BE PART OF THE PUBLISHED PACKAGE
|
||||
// THIS IS FOR DEV PURPOSES ONLY AND WILL NOT BE PART OF THE PUBLISHED PACKAGE
|
||||
// Before opening a PR you should build and test your changes using bin/balena
|
||||
// ****************************************************************************
|
||||
|
||||
@ -9,6 +9,18 @@
|
||||
// operations otherwise, if the pool runs out.
|
||||
process.env.UV_THREADPOOL_SIZE = '64';
|
||||
|
||||
// Allow balena-dev to work with oclif by temporarily
|
||||
// pointing oclif config options to lib/ instead of build/
|
||||
modifyOclifPaths();
|
||||
// Undo changes on exit
|
||||
process.on('exit', function() {
|
||||
modifyOclifPaths(true);
|
||||
});
|
||||
// Undo changes in case of ctrl-v
|
||||
process.on('SIGINT', function() {
|
||||
modifyOclifPaths(true);
|
||||
});
|
||||
|
||||
// Use fast-boot to cache require lookups, speeding up startup
|
||||
require('fast-boot2').start({
|
||||
cacheScope: __dirname + '/..',
|
||||
@ -30,3 +42,24 @@ require('ts-node').register({
|
||||
transpileOnly: true,
|
||||
});
|
||||
require('../lib/app').run();
|
||||
|
||||
// Modify package.json oclif paths from build/ -> lib/, or vice versa
|
||||
function modifyOclifPaths(revert) {
|
||||
const fs = require('fs');
|
||||
const path = './package.json';
|
||||
|
||||
const packageJson = fs.readFileSync(path, 'utf8');
|
||||
const packageObj = JSON.parse(packageJson);
|
||||
|
||||
if(!packageObj.oclif) { return; }
|
||||
|
||||
let oclifSectionText = JSON.stringify(packageObj.oclif);
|
||||
if(!revert) {
|
||||
oclifSectionText = oclifSectionText.replace(/build/g, 'lib')
|
||||
} else {
|
||||
oclifSectionText = oclifSectionText.replace(/lib/g, 'build')
|
||||
}
|
||||
|
||||
packageObj.oclif = JSON.parse(oclifSectionText);
|
||||
fs.writeFileSync(path, `${JSON.stringify(packageObj, null, 2)}\n`, 'utf8');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user