Leo Lamprecht
8 years ago
No known key found for this signature in database
GPG Key ID: EF804E3FF4BBA8AB
2 changed files with
9 additions and
14 deletions
-
lib/hash.js
-
lib/index.js
|
|
@ -5,17 +5,6 @@ import path from 'path' |
|
|
|
// Packages
|
|
|
|
import {readFile} from 'fs-promise' |
|
|
|
|
|
|
|
const listPackage = { |
|
|
|
name: 'static', |
|
|
|
version: '0.0.0', |
|
|
|
scripts: { |
|
|
|
start: 'list ./content' |
|
|
|
}, |
|
|
|
dependencies: { |
|
|
|
list: 'latest' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Computes hashes for the contents of each file given. |
|
|
|
* |
|
|
@ -23,14 +12,15 @@ const listPackage = { |
|
|
|
* @return {Map} |
|
|
|
*/ |
|
|
|
|
|
|
|
export default async function hashes(files, isStatic) { |
|
|
|
export default async function hashes(files, isStatic, pkg) { |
|
|
|
const map = new Map() |
|
|
|
|
|
|
|
await Promise.all(files.map(async name => { |
|
|
|
const filename = path.basename(name) |
|
|
|
let data |
|
|
|
|
|
|
|
if (isStatic && filename === 'package.json') { |
|
|
|
const packageString = JSON.stringify(listPackage, null, 2) |
|
|
|
const packageString = JSON.stringify(pkg, null, 2) |
|
|
|
data = Buffer.from(packageString) |
|
|
|
} else { |
|
|
|
data = await readFile(name) |
|
|
|
|
|
@ -102,7 +102,12 @@ export default class Now extends EventEmitter { |
|
|
|
console.time('> [debug] Computing hashes') |
|
|
|
} |
|
|
|
|
|
|
|
const hashes = await hash(files, isStatic) |
|
|
|
const pkgDetails = {} |
|
|
|
pkgDetails.name = name |
|
|
|
|
|
|
|
Object.assign(pkgDetails, pkg) |
|
|
|
|
|
|
|
const hashes = await hash(files, isStatic, pkgDetails) |
|
|
|
|
|
|
|
if (this._debug) { |
|
|
|
console.timeEnd('> [debug] Computing hashes') |
|
|
|