diff --git a/package.json b/package.json index 68f9eb0..79b22ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@qdivision/chip", - "version": "1.0.3", + "version": "1.0.4", "description": "Easily manage microservices and infrastructure for local development", "files": [ "build/", diff --git a/src/utils/config.ts b/src/utils/config.ts index 12d7d43..a8de1a7 100644 --- a/src/utils/config.ts +++ b/src/utils/config.ts @@ -1,3 +1,4 @@ +import process from 'process'; import fs from 'mz/fs'; import yaml from 'js-yaml'; import { readJsonFile, CHIP_PROCESSES_FILE } from './files'; @@ -17,8 +18,22 @@ export interface ChipConfig { }; } +const readChipYml = async (): Promise => { + while (true) { + try { + return await fs.readFile('./chip.yml', 'utf8'); + } catch (err) { + if (err.code === 'ENOENT' && process.cwd() !== '/') { + process.chdir('../'); + } else { + throw err; + } + } + } +}; + export const readConfig = async (): Promise => { - const chipYml = await fs.readFile('./chip.yml', 'utf8'); + const chipYml = await readChipYml(); const chipConfig = await yaml.safeLoad(chipYml); return chipConfig; };