Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grunt version check cleanup #657

Merged
merged 2 commits into from
Dec 15, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 2 additions & 28 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var sauceTunnelTask = require('./grunt/tasks/sauce-tunnel');
var npmTask = require('./grunt/tasks/npm');
var releaseTasks = require('./grunt/tasks/release');
var npmReactTasks = require('./grunt/tasks/npm-react');
var versionCheckTask = require('./grunt/tasks/version-check');

module.exports = function(grunt) {

Expand Down Expand Up @@ -54,34 +55,7 @@ module.exports = function(grunt) {

grunt.registerTask('npm-react:release', npmReactTasks.buildRelease);

// 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
// them in sync.
var reactVersionExp = /\bReact\.version\s*=\s*['"]([^'"]+)['"];/;
grunt.registerTask('version-check', function() {
var reactVersion = reactVersionExp.exec(
grunt.file.read('./build/modules/React.js')
)[1];
var npmReactVersion = grunt.file.readJSON('./npm-react/package.json').version;
var reactToolsVersion = grunt.config.data.pkg.version;

if (reactVersion !== reactToolsVersion) {
grunt.log.error(
'React version does not match react-tools version. Expected %s, saw %s',
reactToolsVersion,
reactVersion
);
return false;
}
if (npmReactVersion !== reactToolsVersion) {
grunt.log.error(
'npm-react version does not match react-tools veersion. Expected %s, saw %s',
reactToolsVersion,
npmReactVersion
);
return false;
}
});
grunt.registerTask('version-check', versionCheckTask);

grunt.registerTask('build:basic', ['jsx:debug', 'version-check', 'browserify:basic']);
grunt.registerTask('build:addons', ['jsx:debug', 'browserify:addons']);
Expand Down
34 changes: 34 additions & 0 deletions grunt/tasks/version-check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict';

var grunt = require('grunt');


// 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
// them in sync.
var reactVersionExp = /\bReact\.version\s*=\s*['"]([^'"]+)['"];/;

module.exports = function() {
var reactVersion = reactVersionExp.exec(
grunt.file.read('./src/core/React.js')
)[1];
var npmReactVersion = grunt.file.readJSON('./npm-react/package.json').version;
var reactToolsVersion = grunt.config.data.pkg.version;

if (reactVersion !== reactToolsVersion) {
grunt.log.error(
'React version does not match react-tools version. Expected %s, saw %s',
reactToolsVersion,
reactVersion
);
return false;
}
if (npmReactVersion !== reactToolsVersion) {
grunt.log.error(
'npm-react version does not match react-tools veersion. Expected %s, saw %s',
reactToolsVersion,
npmReactVersion
);
return false;
}
};