Skip to content

Commit

Permalink
chore: Modify wrong descriptions about opts.configFiles (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
sttk authored Mar 15, 2022
1 parent b8e4cb5 commit 804e753
Showing 1 changed file with 23 additions and 34 deletions.
57 changes: 23 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Default: `null`

#### opts.configFiles

An object of configuration files to find. Each property is keyed by the default basename of the file being found, and the value is an object of [path arguments](#path-arguments) keyed by unique names.
An object of configuration files to find. Each property is keyed by the default basename of the file being found, and the value is an array of [path arguments](#path-arguments) of which the order indicates priority to find.

**Note:** This option is useful if, for example, you want to support an `.apprc` file in addition to an `appfile.js`. If you only need a single configuration file, you probably don't need this. In addition to letting you find multiple files, this option allows more fine-grained control over how configuration files are located.

Expand Down Expand Up @@ -222,9 +222,9 @@ In this example Liftoff will look for the `.hacker.js` file relative to the `cwd
const MyApp = new Liftoff({
name: 'hacker',
configFiles: {
'.hacker': {
cwd: '.',
},
'.hacker': [
{ path: '.' },
],
},
});
```
Expand All @@ -235,14 +235,14 @@ In this example, Liftoff will look for `.hackerrc` in the home directory.
const MyApp = new Liftoff({
name: 'hacker',
configFiles: {
'.hacker': {
home: {
'.hacker': [
{
path: '~',
extensions: {
rc: null,
},
},
},
],
},
});
```
Expand All @@ -253,12 +253,12 @@ In this example, Liftoff will look in the `cwd` and then lookup the tree for the
const MyApp = new Liftoff({
name: 'hacker',
configFiles: {
'.hacker': {
up: {
'.hacker': [
{
path: '.',
findUp: true,
},
},
],
},
});
```
Expand All @@ -269,12 +269,12 @@ In this example, the `name` is overridden and the key is ignored so Liftoff look
const MyApp = new Liftoff({
name: 'hacker',
configFiles: {
hacker: {
override: {
hacker: [
{
path: '.',
name: '.override',
},
},
],
},
});
```
Expand All @@ -285,12 +285,12 @@ In this example, Liftoff will use the home directory as the `cwd` and looks for
const MyApp = new Liftoff({
name: 'hacker',
configFiles: {
'.hacker': {
home: {
'.hacker': [
{
path: '.',
cwd: '~',
},
},
[,
},
});
```
Expand Down Expand Up @@ -331,31 +331,20 @@ const Liftoff = require('liftoff');
const Hacker = new Liftoff({
name: 'hacker',
configFiles: {
'.hacker': {
home: { path: '.', cwd: '~' },
},
'.hacker': [
{ path: '.', cwd: '~' },
],
},
});
const onExecute = function (env, argv) {
// Do post-execute things
};
const onPrepare = function (env) {
env.configProps = ['home', 'cwd']
.map(function (dirname) {
return env.configFiles['.hacker'][dirname];
})
.filter(function (filePath) {
return Boolean(filePath);
})
.reduce(function (config, filePath) {
return mergeDeep(config, require(filePath));
}, {});

if (env.configProps.hackerfile) {
env.configPath = path.resolve(env.configProps.hackerfile);
const onPrepare = function(env) {
const config = env.config['.hacker'];
if (config.hackerfile) {
env.configPath = path.resolve(config.hackerfile);
env.configBase = path.dirname(env.configPath);
}

Hacker.execute(env, onExecute);
};
Hacker.prepare({}, onPrepare);
Expand Down

0 comments on commit 804e753

Please sign in to comment.