Skip to content

Commit

Permalink
read .zwen file for configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKott committed Apr 2, 2019
1 parent b926719 commit a79a6e2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zwen-react",
"description": "Code generator CLI for projects using react and redux",
"version": "0.7.4",
"version": "0.7.5",
"author": "Zweitag GmbH @zweitag",
"contributors": [
"Alex Kott <[email protected]>",
Expand Down
24 changes: 24 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import fs from 'fs';
import path from 'path';

const defaultConfig = {
srcDir: 'src',
};

let config = {
...defaultConfig,
};

try {
const configFile = fs.readFileSync(path.join(process.cwd(), '.zwen'), 'utf-8');
const userConfig = JSON.parse(configFile);

config = {
...config,
...userConfig,
};

// tslint:disable-next-line no-empty
} catch (error) {}

export default config;
10 changes: 1 addition & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
import '@babel/polyfill';
import './prototypes';

import chalk from 'chalk';
import path from 'path';
import yeoman from 'yeoman-environment';

import config from './config';
import { registeredGenerators } from './generators';
import logger from './logger';
import { Flags, GeneratorOptions } from './types';

const defaultConfig = {
srcDir: 'src',
};
// TODO: read user config from .zwen file
const config = {
...defaultConfig,
};

module.exports = (args: string[], flags: Flags) => {
const [command, destPath] = args;

Expand Down

0 comments on commit a79a6e2

Please sign in to comment.