Files
cypress/cli/scripts/build.js
Brian Mann 2333d04a54 secure cookie error crash (#2685)
- fixes #1264 
- fixes #1321 
- fixes #1799  
- fixes #2689
- fixes #2688
- fixes #2687 	
- fixes #2686
2018-11-01 12:34:37 -04:00

71 lines
1.6 KiB
JavaScript

const _ = require('lodash')
const path = require('path')
const fs = require('../lib/fs')
// grab the current version and a few other properties
// from the root package.json
const {
version,
description,
author,
homepage,
license,
bugs,
repository,
keywords,
} = require('@packages/root')
// the rest of properties should come from the package.json in CLI folder
const packageJsonSrc = path.join('package.json')
const packageJsonDest = path.join('build', 'package.json')
function preparePackageForNpmRelease (json) {
// modify the existing package.json
// to prepare it for releasing to npm
delete json.devDependencies
delete json['private']
_.extend(json, {
version,
description,
author,
homepage,
license,
bugs,
repository,
keywords,
types: 'types', // typescript types
scripts: {
postinstall: 'node index.js --exec install',
size: 't=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";',
},
})
return json
}
function makeUserPackageFile () {
return fs.readJsonAsync(packageJsonSrc)
.then(preparePackageForNpmRelease)
.then((json) => {
return fs.outputJsonAsync(packageJsonDest, json, {
spaces: 2,
})
.return(json) // returning package json object makes it easy to test
})
}
module.exports = makeUserPackageFile
if (!module.parent) {
makeUserPackageFile()
.catch((err) => {
/* eslint-disable no-console */
console.error('Could not write user package file')
console.error(err)
/* eslint-enable no-console */
process.exit(-1)
})
}