From bb6bced1f3f1df813b431fe87060ce0378a5df27 Mon Sep 17 00:00:00 2001 From: Joel Kemp Date: Sun, 16 Dec 2018 13:11:00 -0500 Subject: [PATCH] Change to options.fileSystem for consistency Refs https://github.com/dependents/node-filing-cabinet/pull/68#discussion_r241988175 --- Readme.md | 2 +- index.js | 6 ++++-- test/index.js | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Readme.md b/Readme.md index 8d839df..119bc50 100644 --- a/Readme.md +++ b/Readme.md @@ -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 diff --git a/index.js b/index.js index 23b3213..21a1d97 100644 --- a/index.js +++ b/index.js @@ -130,7 +130,7 @@ 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) { @@ -138,7 +138,9 @@ precinct.paperwork = function(filename, options) { 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; diff --git a/test/index.js b/test/index.js index 68e440a..1806ded 100644 --- a/test/index.js +++ b/test/index.js @@ -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'); @@ -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);