Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow chip to be run from subdirectories #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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/",
Expand Down
17 changes: 16 additions & 1 deletion src/utils/config.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -17,8 +18,22 @@ export interface ChipConfig {
};
}

const readChipYml = async (): Promise<string> => {
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<ChipConfig> => {
const chipYml = await fs.readFile('./chip.yml', 'utf8');
const chipYml = await readChipYml();
const chipConfig = await yaml.safeLoad(chipYml);
return chipConfig;
};
Expand Down