mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-26 19:09:32 -06:00
chore: publish packages with the correct branch name in buildInfo (#27682)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const _ = require('lodash')
|
||||
const path = require('path')
|
||||
const shell = require('shelljs')
|
||||
const minimist = require('minimist')
|
||||
|
||||
const fs = require('../lib/fs')
|
||||
|
||||
@@ -24,7 +25,7 @@ function getStdout (cmd) {
|
||||
return shell.exec(cmd).trim()
|
||||
}
|
||||
|
||||
function preparePackageForNpmRelease (json) {
|
||||
function preparePackageForNpmRelease (json, branchName) {
|
||||
// modify the existing package.json
|
||||
// to prepare it for releasing to npm
|
||||
delete json.devDependencies
|
||||
@@ -36,7 +37,7 @@ function preparePackageForNpmRelease (json) {
|
||||
_.extend(json, {
|
||||
version,
|
||||
buildInfo: {
|
||||
commitBranch: process.env.CIRCLE_BRANCH || getStdout('git branch --show-current'),
|
||||
commitBranch: branchName || process.env.CIRCLE_BRANCH || getStdout('git branch --show-current'),
|
||||
commitSha: getStdout('git rev-parse HEAD'),
|
||||
commitDate: new Date(getStdout('git show -s --format=%ci')).toISOString(),
|
||||
stable: false,
|
||||
@@ -57,9 +58,9 @@ function preparePackageForNpmRelease (json) {
|
||||
return json
|
||||
}
|
||||
|
||||
function makeUserPackageFile () {
|
||||
function makeUserPackageFile (branchName) {
|
||||
return fs.readJsonAsync(packageJsonSrc)
|
||||
.then(preparePackageForNpmRelease)
|
||||
.then((json) => preparePackageForNpmRelease(json, branchName))
|
||||
.then((json) => {
|
||||
return fs.outputJsonAsync(packageJsonDest, json, {
|
||||
spaces: 2,
|
||||
@@ -71,7 +72,9 @@ function makeUserPackageFile () {
|
||||
module.exports = makeUserPackageFile
|
||||
|
||||
if (!module.parent) {
|
||||
makeUserPackageFile()
|
||||
const args = minimist(process.argv)
|
||||
|
||||
makeUserPackageFile(args.branch)
|
||||
.catch((err) => {
|
||||
/* eslint-disable no-console */
|
||||
console.error('Could not write user package file')
|
||||
|
||||
Reference in New Issue
Block a user