Skip to content

Commit

Permalink
Remove Gruntfile api - Fix #744
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed Dec 2, 2016
1 parent fedb2fb commit 1b6eede
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 64 deletions.
28 changes: 0 additions & 28 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ var minimist = require('minimist');
var runAsync = require('run-async');
var through = require('through2');
var userHome = require('user-home');
var GruntfileEditor = require('gruntfile-editor');
var FileEditor = require('mem-fs-editor');
var pathIsAbsolute = require('path-is-absolute');
var pathExists = require('path-exists');
Expand Down Expand Up @@ -137,33 +136,6 @@ var Base = module.exports = function Base(args, options) {

// ensure source/destination path, can be configured from subclasses
this.sourceRoot(path.join(path.dirname(this.resolved), 'templates'));

// Only instantiate the Gruntfile API when requested
Object.defineProperty(this, 'gruntfile', {
get: function () {
if (!this.env.gruntfile) {
var gruntfile = '';
var gruntPath = this.destinationPath('Gruntfile.js');

if (this.fs.exists(gruntPath)) {
gruntfile = this.fs.read(gruntPath);
}

this.env.gruntfile = new GruntfileEditor(gruntfile);
}

// Schedule the creation/update of the Gruntfile
this.env.runLoop.add('writing', function (done) {
this.fs.write(
this.destinationPath('Gruntfile.js'),
this.env.gruntfile.toString()
);
done();
}.bind(this), { once: 'gruntfile:write' });

return this.env.gruntfile;
}
});
};

util.inherits(Base, events.EventEmitter);
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"find-up": "^1.0.0",
"github-username": "^2.0.0",
"glob": "^7.0.3",
"gruntfile-editor": "^1.0.0",
"istextorbinary": "^2.1.0",
"lodash": "^4.11.1",
"mem-fs-editor": "^2.0.0",
Expand Down
35 changes: 0 additions & 35 deletions test/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -913,41 +913,6 @@ describe('Base', function () {
});
});

describe('#gruntfile', function () {
beforeEach(function () {
this.GruntfileGenerator = Base.extend({
grunt: function () {
this.gruntfile.insertConfig('foo', '{}');
}
});

this.gruntGenerator = new this.GruntfileGenerator([], {
resolved: 'unknown',
namespace: 'dummy',
env: this.env,
'skip-install': true,
force: true
});
});

it('expose the gruntfile editor API', function () {
assert(this.gruntGenerator.gruntfile instanceof require('gruntfile-editor'));
});

it('uses the gruntfile editor of the Env if available', function () {
this.gruntGenerator.env.gruntfile = 'foo';
assert.equal(this.gruntGenerator.gruntfile, 'foo');
});

it('schedule gruntfile writing on the write Queue', function (done) {
this.gruntGenerator.run(function () {
var gruntfile = this.dummy.fs.read(this.dummy.destinationPath('Gruntfile.js'));
assert(gruntfile.indexOf('foo:') > 0);
done();
}.bind(this));
});
});

describe('#templatePath()', function () {
it('joins path to the source root', function () {
assert.equal(
Expand Down

0 comments on commit 1b6eede

Please sign in to comment.