Skip to content

Commit

Permalink
Change to options.fileSystem for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjoelkemp committed Dec 16, 2018
1 parent eb83316 commit 3a5f991
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var deps2 = paperwork('styles.scss');
Supported options:

* `includeCore`: (default: true) set to `false` to exclude core Node dependencies from the list of dependencies.
* `fs`: (default: undefined) set to an alternative `fs` implementation that will be used to read the file path.
* `fileSystem`: (default: undefined) set to an alternative `fs` implementation that will be used to read the file path.
* You may also pass detective-specific configuration like you would to `precinct(content, options)`.

#### CLI
Expand Down
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,17 @@ function assign(o1, o2) {
* @param {String} filename
* @param {Object} [options]
* @param {Boolean} [options.includeCore=true] - Whether or not to include core modules in the dependency list
* @param {Object} [options.fs=undefined] - An alternative fs implementation to use for reading the file path.
* @param {Object} [options.fileSystem=undefined] - An alternative fs implementation to use for reading the file path.
* @return {String[]}
*/
precinct.paperwork = function(filename, options) {
options = assign({
includeCore: true
}, options || {});

var fileSystem = options.fs || fs;
// Note: released with options.fs but intended options.fileSystem for consistency in the community
// TODO: Remove options.fs in the next major version update
var fileSystem = options.fileSystem || options.fs || fs;
var content = fileSystem.readFileSync(filename, 'utf8');
var ext = path.extname(filename);
var type;
Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ describe('node-precinct', function() {
});

describe('paperwork', function() {
it('uses fs from options if provided', function() {
it('uses filesystem from options if provided', function() {
var fsMock = {
readFileSync: function(path, encoding) {
assert.equal(path, '/foo.js');
Expand All @@ -161,7 +161,7 @@ describe('node-precinct', function() {
};

var options = {
fs: fsMock
fileSystem: fsMock
};
var results = precinct.paperwork('/foo.js', options);
assert.equal(results.length, 1);
Expand Down

0 comments on commit 3a5f991

Please sign in to comment.