Browse Source

Adapt deployment name from package

master
Leo Lamprecht 8 years ago
parent
commit
b563900702
No known key found for this signature in database GPG Key ID: EF804E3FF4BBA8AB
  1. 16
      lib/hash.js
  2. 7
      lib/index.js

16
lib/hash.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)

7
lib/index.js

@ -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')

Loading…
Cancel
Save