Skip to content

Commit

Permalink
build: ReactTestRenderer package
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdustan committed Jul 27, 2016
1 parent 0292d34 commit 8ca74ac
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ module.exports = function(grunt) {
grunt.registerTask('npm-react-addons:release', npmReactAddonsTasks.buildReleases);
grunt.registerTask('npm-react-addons:pack', npmReactAddonsTasks.packReleases);

var npmReactTestRendererTasks = require('./grunt/tasks/npm-react-test');
grunt.registerTask('npm-react-test:release', npmReactTestRendererTasks.buildRelease);
grunt.registerTask('npm-react-test:pack', npmReactTestRendererTasks.packRelease);

grunt.registerTask('version-check', function() {
// Use gulp here.
spawnGulp(['version-check'], null, this.async());
Expand Down Expand Up @@ -146,6 +150,8 @@ module.exports = function(grunt) {
'npm-react-native:pack',
'npm-react-addons:release',
'npm-react-addons:pack',
'npm-react-test:release',
'npm-react-test:pack',
'compare_size',
]);

Expand Down
46 changes: 46 additions & 0 deletions grunt/tasks/npm-react-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'use strict';

var fs = require('fs');
var grunt = require('grunt');

var src = 'packages/react-test-renderer/';
var dest = 'build/packages/react-test-renderer/';

function buildRelease() {
if (grunt.file.exists(dest)) {
grunt.file.delete(dest);
}

// Copy to build/packages/react-native-renderer
var mappings = [].concat(
grunt.file.expandMapping('**/*', dest, {cwd: src}),
grunt.file.expandMapping('{LICENSE,PATENTS}', dest)
);
mappings.forEach(function(mapping) {
var mappingSrc = mapping.src[0];
var mappingDest = mapping.dest;
if (grunt.file.isDir(mappingSrc)) {
grunt.file.mkdir(mappingDest);
} else {
grunt.file.copy(mappingSrc, mappingDest);
}
});
}

function packRelease() {
var done = this.async();
var spawnCmd = {
cmd: 'npm',
args: ['pack', 'packages/react-test-renderer'],
};
grunt.util.spawn(spawnCmd, function() {
var buildSrc = 'react-test-renderer-' + grunt.config.data.pkg.version + '.tgz';
var buildDest = 'build/packages/react-test-renderer.tgz';
fs.rename(buildSrc, buildDest, done);
});
}

module.exports = {
buildRelease: buildRelease,
packRelease: packRelease,
};
4 changes: 4 additions & 0 deletions packages/react-test-renderer/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

'use strict';

module.exports = require('react/lib/ReactTestRenderer');
21 changes: 21 additions & 0 deletions packages/react-test-renderer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "react-test-renderer",
"version": "16.0.0-alpha",
"description": "React package for snapshot testing.",
"main": "index.js",
"repository": "facebook/react",
"keywords": [
"react",
"react-native",
"react-testing"
],
"license": "BSD-3-Clause",
"bugs": {
"url": "https://github.com/facebook/react/issues"
},
"homepage": "https://facebook.github.io/react-native/",
"dependencies": {
"react": "^16.0.0-alpha"
}
}

0 comments on commit 8ca74ac

Please sign in to comment.