Skip to content

Commit

Permalink
configPath cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
David Clark committed Jul 18, 2017
1 parent e4baf6d commit 9d2ae4e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@
## Head

- Added: `sync` option.
- Fixed: `options.configPath` and `--config` flag are respected.

## 2.1.3

Expand Down
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -188,6 +188,12 @@ If the option `sync` is `true`, though, `transform` should be a synchronous func

The reason you might use this option instead of simply applying your transform function some other way is that *the transformed result will be cached*. If your transformation involves additional filesystem I/O or other potentially slow processing, you can use this option to avoid repeating those steps every time a given configuration is loaded.

##### configPath

Type: `string`

If provided, cosmiconfig will load and parse a config from this path, and will not perform its usual search.

### Instance methods (on `explorer`)

#### `load([searchPath, configPath])`
Expand Down
23 changes: 0 additions & 23 deletions test/config-file.test.js

This file was deleted.

14 changes: 14 additions & 0 deletions test/successful-directories.test.js
Expand Up @@ -660,3 +660,17 @@ test('with rcExtensions, find .foorc.js in first searched dir', function (assert
teardown(assert, err);
}
});

test('options.configPath is respected', function (assert) {
var configPath = absolutePath('fixtures/foo.json');
var explorer = cosmiconfig('foo', { configPath: configPath });
explorer.load('./path/does/not/exist').then(function (result) {
assert.deepEqual(result.config, {
foo: true,
});
assert.equal(result.filepath, configPath);
assert.end();
}).catch(function (err) {
assert.end(err);
});
});

0 comments on commit 9d2ae4e

Please sign in to comment.