diff --git a/packager/package.json b/packager/package.json index 66f7b1b2c..0afcd3c3c 100644 --- a/packager/package.json +++ b/packager/package.json @@ -1,6 +1,6 @@ { "name": "react-native-cli", - "version": "0.1.0", + "version": "0.1.1", "description": "Build native apps with React!", "repository": { "type": "git", diff --git a/packager/react-packager/src/JSTransformer/Cache.js b/packager/react-packager/src/JSTransformer/Cache.js index b9c5b8c14..bad0dadb3 100644 --- a/packager/react-packager/src/JSTransformer/Cache.js +++ b/packager/react-packager/src/JSTransformer/Cache.js @@ -1,13 +1,14 @@ 'use strict'; -var path = require('path'); -var version = require('../../../../package.json').version; -var tmpdir = require('os').tmpDir(); -var isAbsolutePath = require('absolute-path'); +var _ = require('underscore'); +var crypto = require('crypto'); var declareOpts = require('../lib/declareOpts'); var fs = require('fs'); -var _ = require('underscore'); +var isAbsolutePath = require('absolute-path'); +var path = require('path'); var q = require('q'); +var tmpdir = require('os').tmpDir(); +var version = require('../../../../package.json').version; var Promise = q.Promise; @@ -146,15 +147,15 @@ function loadCacheSync(cachePath) { } function cacheFilePath(options) { + var hash = crypto.createHash('md5'); + hash.update(version); + var roots = options.projectRoots.join(',').split(path.sep).join('-'); + hash.update(roots); + var cacheVersion = options.cacheVersion || '0'; - return path.join( - tmpdir, - [ - 'react-packager-cache', - version, - cacheVersion, - roots, - ].join('-') - ); + hash.update(cacheVersion); + + var name = 'react-packager-cache-' + hash.digest('hex'); + return path.join(tmpdir, name); } diff --git a/packager/react-packager/src/JSTransformer/__tests__/Cache-test.js b/packager/react-packager/src/JSTransformer/__tests__/Cache-test.js index 97a500973..f5b55f056 100644 --- a/packager/react-packager/src/JSTransformer/__tests__/Cache-test.js +++ b/packager/react-packager/src/JSTransformer/__tests__/Cache-test.js @@ -4,6 +4,7 @@ jest .dontMock('underscore') .dontMock('path') .dontMock('absolute-path') + .dontMock('crypto') .dontMock('../Cache'); var q = require('q'); @@ -19,7 +20,7 @@ describe('JSTransformer Cache', function() { Cache = require('../Cache'); }); - describe('getting/settig', function() { + describe('getting/setting', function() { it('calls loader callback for uncached file', function() { var cache = new Cache({projectRoots: ['/rootDir']}); var loaderCb = jest.genMockFn().mockImpl(function() {