Skip to content

Commit

Permalink
Merge pull request #10 from yeoman/mem-fs
Browse files Browse the repository at this point in the history
Expose mem-fs on the environment
  • Loading branch information
SBoudrias committed Nov 6, 2014
2 parents 8cf0c65 + 9e8276d commit 61ae516
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var chalk = require('chalk');
var _ = require('lodash');
var GroupedQueue = require('grouped-queue');
var untildify = require('untildify');
var memFs = require('mem-fs');

var debug = require('debug')('generators:environment');

Expand Down Expand Up @@ -47,6 +48,7 @@ var Environment = module.exports = function Environment(args, opts, adapter) {
this.store = new Store();

this.runLoop = new GroupedQueue(Environment.queues);
this.sharedFs = memFs.create();

this.lookups = ['.', 'generators', 'lib/generators'];
this.aliases = [];
Expand Down Expand Up @@ -405,6 +407,9 @@ Environment.enforceUpdate = function (env) {
env.runLoop = new GroupedQueue(['initializing', 'prompting', 'configuring', 'default',
'writing', 'conflicts', 'install', 'end']);
}
if (!env.sharedFs) {
env.sharedFs = memFs.create();
}
return env;
};

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"inquirer": "^0.8.0",
"lodash": "^2.4.1",
"log-symbols": "^1.0.1",
"mem-fs": "SBoudrias/mem-fs",
"text-table": "^0.2.0",
"untildify": "^1.0.0",
"yeoman-generator": "^0.17.7"
Expand Down
10 changes: 10 additions & 0 deletions test/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ describe('Environment', function () {
var env = new Environment(null, null, dummyAdapter);
assert.equal(env.adapter, dummyAdapter, 'Not the adapter provided');
});

it('instantiates a mem-fs instance', function () {
assert.ok(this.env.sharedFs);
});
});

describe('#help()', function () {
Expand Down Expand Up @@ -442,6 +446,7 @@ describe('Environment', function () {
this.env = new Environment();
delete this.env.adapter;
delete this.env.runLoop;
delete this.env.sharedFs;
});

it('add an adapter', function () {
Expand All @@ -453,6 +458,11 @@ describe('Environment', function () {
Environment.enforceUpdate(this.env);
assert(this.env.runLoop);
});

it('add a shared mem-fs instance', function () {
Environment.enforceUpdate(this.env);
assert(this.env.sharedFs);
});
});

describe('.createEnv()', function () {
Expand Down

0 comments on commit 61ae516

Please sign in to comment.