Skip to content
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
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ The only configuration you need to provide is a mapping, which maps a folder on
host = "https://example.org"
```

same example saved as default.json
```json
{ "mappings": {
"example": {
"host": "https://example.org"
}
}
}
```
This is the minimal required configuration. It will map `http://localhost:<port>/example/*` to `https://example.org/*`.


Expand Down Expand Up @@ -174,6 +183,20 @@ Date: Thu, 11 Feb 2016 17:24:10 GMT
{"status":"ok"}
```


## CLI

| param | description |
|------------------|--------------------------------------------------------------------------------------|
| `root` or `(r)` | This is the folder where mock files will be saved |
| `config` or `(c)`| This is the folder where config files are located |
| `name` or `(n)` | This is config file name |

And example:
```
npm run start --config "./config_dir" --name "amp_config_file_name" --root "./config_dir/mocks"
```

## Advanced

There are some more advanced configuration options available. For example, AMP uses [node-config][nc] to manage its config files, so there are options for providing different config files per environment.
Expand Down
17 changes: 17 additions & 0 deletions src/argv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* globals process */
import minimist from 'minimist';

const argv = minimist(process.argv.slice(2), {alias: {
root: ['r', 'data'],
config: ['c'],
name: ['n']
}});

if (argv.config) {
process.env.NODE_CONFIG_DIR = argv.config;
}
if (argv.name) {
process.env.NODE_ENV = argv.name;
}

export default argv;
4 changes: 1 addition & 3 deletions src/cli.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/* globals process */
import minimist from 'minimist';
import argv from './argv';
import cacher from './cacher';
import server from './serve';
import config from 'config';

const argv = minimist(process.argv.slice(2), {alias: {root: ['r', 'data']}});

if (argv.root) {
cacher.root = argv.root;
}
Expand Down