-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
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
4 changed files
with
113 additions
and
56 deletions.
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
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,20 @@ | ||
var path = require('path') | ||
|
||
module.exports = function (grunt) { | ||
grunt.registerTask( 'casper', function (id) { | ||
var done = this.async(), | ||
file = id ? id + '.js' : '' | ||
grunt.util.spawn({ | ||
cmd: 'casperjs', | ||
args: ['test', '--concise', 'specs/' + file], | ||
opts: { | ||
stdio: ['ignore', process.stdout, 'ignore'], | ||
cwd: path.resolve('test/functional') | ||
} | ||
}, function (err, res) { | ||
if (err) grunt.fail.fatal(res.stdout || 'CasperJS test failed') | ||
grunt.log.writeln(res.stdout) | ||
done() | ||
}) | ||
}) | ||
} |
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,19 @@ | ||
var fs = require('fs') | ||
|
||
module.exports = function (grunt) { | ||
grunt.registerTask( 'jsc', function () { | ||
var done = this.async() | ||
grunt.util.spawn({ | ||
cmd: './node_modules/jscoverage/bin/jscoverage', | ||
args: ['./test/vue.test.js'], | ||
opts: { | ||
stdio: 'inherit' | ||
} | ||
}, function (err, res) { | ||
if (err) grunt.fail.fatal(res.stdout || 'Jscoverage instrumentation failed') | ||
grunt.log.writeln(res.stdout) | ||
fs.unlinkSync('./test/vue.test.js') | ||
done() | ||
}) | ||
}) | ||
} |
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,64 @@ | ||
var semver = require('semver'), | ||
readline = require('readline'), | ||
exec = require('child_process').exec | ||
|
||
module.exports = function (grunt) { | ||
|
||
grunt.registerTask('version', function (version) { | ||
;['package', 'bower', 'component'].forEach(function (file) { | ||
file = './' + file + '.json' | ||
var json = grunt.file.read(file) | ||
json = json.replace(/"version"\s*:\s*"(.+?)"/, '"version": "' + version + '"') | ||
grunt.file.write(file, json) | ||
}) | ||
}) | ||
|
||
grunt.registerTask('git', function (version) { | ||
exec( | ||
'git add -A;' + | ||
'git commit -m "Release v' + version + '";' + | ||
'git tag v' + version + ';' + | ||
'git push;' + | ||
'git push origin v' + version, | ||
this.async() | ||
) | ||
}) | ||
|
||
grunt.registerTask('release', function (version) { | ||
|
||
var done = this.async(), | ||
current = grunt.config('pkg.version'), | ||
next = semver.inc(current, version || 'patch') | ||
|
||
if (!next) { | ||
if (!semver.valid(version)) { | ||
return grunt.fail.warn('Invalid version.') | ||
} | ||
if (semver.lt(version, current)) { | ||
return grunt.fail.warn('Version is older than current.') | ||
} | ||
} | ||
|
||
readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout | ||
}).question('Releasing version v' + next + '. Continue? (Y/n)', function (answer) { | ||
if (!answer || answer.toLowerCase() === 'y') { | ||
console.log( | ||
'\n\x1b[1m\x1b[34m' + | ||
'Releasing: v' + next + | ||
'\x1b[39m\x1b[22m' | ||
) | ||
grunt.config.set('version', next) | ||
grunt.task.run([ | ||
'jshint', | ||
'test', | ||
'version:' + next, | ||
'uglify', | ||
'git:' + next | ||
]) | ||
} | ||
done() | ||
}) | ||
}) | ||
} |