Merge pull request #344 from benjamn/fix-silent-test-failure-due-to-requiring-React

Use a regular expression to parse out React.version
This commit is contained in:
Paul O’Shannessy 2013-09-11 16:03:59 -07:00
commit c8ec4595bb
1 changed files with 4 additions and 1 deletions

View File

@ -55,8 +55,11 @@ module.exports = function(grunt) {
// Check that the version we're exporting is the same one we expect in the // Check that the version we're exporting is the same one we expect in the
// package. This is not an ideal way to do this, but makes sure that we keep // package. This is not an ideal way to do this, but makes sure that we keep
// them in sync. // them in sync.
var reactVersionExp = /\bReact\.version\s*=\s*['"]([^'"]+)['"];/;
grunt.registerTask('version-check', function() { grunt.registerTask('version-check', function() {
var version = require('./build/modules/React').version; var version = reactVersionExp.exec(
grunt.file.read('./build/modules/React.js')
)[1];
var expectedVersion = grunt.config.data.pkg.version; var expectedVersion = grunt.config.data.pkg.version;
if (version !== expectedVersion) { if (version !== expectedVersion) {
grunt.log.error('Versions do not match. Expected %s, saw %s', expectedVersion, version); grunt.log.error('Versions do not match. Expected %s, saw %s', expectedVersion, version);