Skip to content

Commit 81581a1

Browse files
authored
Merge pull request #96 from greydaemon/DOT-4737
[DOT-4737] : Added env variable support in storybook cli for Baseline Branch, Branch Name.
2 parents 9a4d090 + b0f44eb commit 81581a1

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

commands/storybook.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ async function storybook(serve, options) {
114114
}
115115

116116
let commit = await getLastCommit();
117+
let baseLine;
118+
if (process.env.BASELINE_BRANCH !== undefined && process.env.BASELINE_BRANCH !== null && process.env.BASELINE_BRANCH !== '')
119+
baseLine = process.env.BASELINE_BRANCH
120+
console.log(`Baseline branch set :${baseLine}`)
117121
let payload = {
118122
downloadURL: url.substring(url.search(/.com/)+5, url.search(/.zip/)+4),
119123
uploadId: uploadId,
@@ -126,13 +130,14 @@ async function storybook(serve, options) {
126130
customViewports: storybookConfig.customViewports
127131
},
128132
git: {
129-
branch: commit.branch,
130-
commitId: commit.shortHash,
131-
commitAuthor: commit.author.name,
132-
commitMessage: commit.subject,
133+
branch: process.env.BRANCH_NAME ? process.env.BRANCH_NAME: commit.branch,
134+
commitId: commit.shortHash,
135+
commitAuthor: commit.author.name,
136+
commitMessage: commit.subject,
133137
githubURL: process.env.GITHUB_URL || '',
134138
},
135-
buildName: buildName
139+
buildName: buildName,
140+
baseline: baseLine?? "",
136141
}
137142

138143
// Call static render API

index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ program.command('storybook')
4141
console.log('SmartUI Storybook CLI v' + version);
4242
await checkUpdate(version, options);
4343
console.log('\n');
44-
if (options.buildName === '') {
45-
console.log(`Error: The '--buildName' option cannot be an empty string.`);
44+
// Check if buildName is undefined or empty string
45+
if (options.buildName === undefined || options.buildName === '') {
46+
const error = {
47+
"error": "MISSING_BUILD_NAME",
48+
"message": "The --buildName flag requires a value."
49+
};
50+
console.log(JSON.stringify(error, null, 2));
4651
process.exit(1);
4752
}
4853
if (options.config) {

0 commit comments

Comments
 (0)