Repository URL to install this package:
|
Version:
1.2.8 ▾
|
import { resolveToRoot } from '../resolveToRoot'
import { read, write } from 'flipfile'
import { config } from '@skava/di'
const pkg = config.get('package')
function create(requirePath: string) {
const resolvedPath = resolveToRoot(requirePath)
write(resolvedPath, JSON.stringify(pkg, undefined, 2))
}
function tryRequireOrCreate(requirePath: string) {
const resolvedPath = resolveToRoot(requirePath)
try {
return require.resolve(resolvedPath)
} catch (requireException) {
create(requirePath)
return require.resolve(resolvedPath)
}
}
const distPkgPath = tryRequireOrCreate(process.env.OUTPUT_PACKAGE_JSON_PATH)
const distPkg = require(distPkgPath)
console.log({ distPkgPath, distPkg })
// distPkg.env.FEATURE = Boolean(process.env.FEATURE)
// distPkg.env.QA = Boolean(process.env.QA)
// distPkg.env.PREPROD = Boolean(process.env.PREPROD)
distPkg.dependencies = pkg.dependencies
write(distPkgPath, JSON.stringify(distPkg, undefined, 2))