fbjs-scripts
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -0,1 +1,22 @@ | ||
## master | ||
## [1.1.0] | ||
### Changed | ||
- Removed `rootDir` from consideration to compute the cache key in `createCacheKeyFunction`. | ||
- Added an additional array of values for the cache breaker in `createCacheKeyFunction`. | ||
## [1.0.1] | ||
### Fixed | ||
- Fixed `babel-preset-fbjs` dependency | ||
## [1.0.0] - 2018-09-18 | ||
### Changed | ||
- Migrated to Babel 7 | ||
## [0.8.3] - 2018-04-18 | ||
@@ -2,0 +23,0 @@ |
@@ -12,21 +12,43 @@ /** | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
function buildCacheKey(files, base) { | ||
return files.reduce( | ||
(src, fileName) => src + fs.readFileSync(fileName), | ||
base | ||
); | ||
function getGlobalCacheKey(files, values) { | ||
const presetVersion = require('../package').dependencies['babel-preset-fbjs']; | ||
const chunks = [ | ||
process.env.NODE_ENV, | ||
process.env.BABEL_ENV, | ||
presetVersion, | ||
...values, | ||
...files.map(file => fs.readFileSync(file)), | ||
]; | ||
return chunks | ||
.reduce( | ||
(hash, chunk) => hash.update('\0', 'utf-8').update(chunk || ''), | ||
crypto.createHash('md5') | ||
) | ||
.digest('hex'); | ||
} | ||
module.exports = files => { | ||
const presetVersion = require('../package').dependencies['babel-preset-fbjs']; | ||
const cacheKey = buildCacheKey(files, presetVersion); | ||
function getCacheKeyFunction(globalCacheKey) { | ||
return (src, file, configString, options) => { | ||
const {instrument, config} = options; | ||
const rootDir = config && config.rootDir; | ||
return crypto | ||
.createHash('md5') | ||
.update(cacheKey) | ||
.update(src + file + configString) | ||
.update(options && options.instrument ? 'instrument' : '') | ||
.update(globalCacheKey) | ||
.update('\0', 'utf8') | ||
.update(src) | ||
.update('\0', 'utf8') | ||
.update(rootDir ? path.relative(config.rootDir, file) : '') | ||
.update('\0', 'utf8') | ||
.update(instrument ? 'instrument' : '') | ||
.digest('hex'); | ||
}; | ||
} | ||
module.exports = (files = [], values = []) => { | ||
return getCacheKeyFunction(getGlobalCacheKey(files, values)); | ||
}; |
{ | ||
"name": "fbjs-scripts", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "A bundle of helpful scripts used in projects consuming fbjs.", | ||
@@ -5,0 +5,0 @@ "repository": "facebook/fbjs", |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
55288
370
8
2