Skip to content

Commit

Permalink
Make Storage configPath parameter required
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed Jan 6, 2015
1 parent 8e9e5ae commit 72d8689
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
8 changes: 4 additions & 4 deletions lib/util/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ var _ = require('lodash');
*
* @constructor
* @param {String} name The name of the new storage (this is a namespace)
* @param {mem-fs-editor} fs A mem-fs editor instance
* @param {String} configPath The filepath used as a storage. `.yo-rc.json` is used
* by default
* @param {mem-fs-editor} fs A mem-fs editor instance
* @param {String} configPath The filepath used as a storage.
*
* @example
* var MyGenerator = yeoman.generators.base.extend({
Expand All @@ -24,8 +23,9 @@ var _ = require('lodash');

var Storage = module.exports = function Storage(name, fs, configPath) {
assert(name, 'A name parameter is required to create a storage');
assert(configPath, 'A config filepath is required to create a storage');

this.path = configPath || path.join(process.cwd(), '.yo-rc.json');
this.path = configPath;
this.name = name;
this.fs = fs;

Expand Down
11 changes: 4 additions & 7 deletions test/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,10 @@ describe('Storage', function () {
assert.equal(this.store.get('foo'), 'bar');
});

it('defaults store path to `.yo-rc.json`', function () {
process.chdir(tmpdir);
var store = new Storage('yo', this.fs);
store.set('foo', 'bar');

var fileContent = this.fs.readJSON('.yo-rc.json');
assert.equal(fileContent.yo.foo, 'bar');
it('a config path is required', function () {
assert.throws(function () {
new Storage('yo', this.fs);
});
});

describe('#get()', function () {
Expand Down

0 comments on commit 72d8689

Please sign in to comment.