-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
test/fixtures/load-npm-tasks/node_modules/grunt-foo-plugin/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
test/fixtures/load-npm-tasks/node_modules/grunt-foo-plugin/tasks/foo.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"private": true, | ||
"name": "load-npm-tasks", | ||
"devDependencies": { | ||
"grunt-foo-plugin": "1.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* grunt | ||
* http://gruntjs.com/ | ||
* | ||
* Copyright (c) 2016 "Cowboy" Ben Alman | ||
* Licensed under the MIT license. | ||
* https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var Log = require('grunt-legacy-log').Log; | ||
var assert = require('assert'); | ||
var through = require('through2'); | ||
|
||
module.exports = function(grunt) { | ||
grunt.file.setBase('../fixtures/load-npm-tasks'); | ||
|
||
// Create a custom log to assert output | ||
var stdout = []; | ||
var oldlog = grunt.log; | ||
var stream = through(function(data, enc, next) { | ||
stdout.push(data.toString()); | ||
next(null, data); | ||
}); | ||
stream.pipe(process.stdout); | ||
var log = new Log({ | ||
grunt: grunt, | ||
outStream: stream, | ||
}); | ||
grunt.log = log; | ||
|
||
// Load a npm task | ||
grunt.loadNpmTasks('grunt-foo-plugin'); | ||
|
||
// Run them | ||
grunt.registerTask('default', ['foo', 'done']); | ||
|
||
// Assert they loaded and ran correctly | ||
grunt.registerTask('done', function() { | ||
grunt.log = oldlog; | ||
stdout = stdout.join('\n'); | ||
try { | ||
assert.ok(stdout.indexOf('foo has ran.') !== -1, 'oh-four task should have ran.'); | ||
} catch (err) { | ||
grunt.log.subhead(err.message); | ||
grunt.log.error('Expected ' + err.expected + ' but actually: ' + err.actual); | ||
throw err; | ||
} | ||
}); | ||
}; |