Skip to content

Commit 015b355

Browse files
Merge pull request #97 from greydaemon/DOT-4737
[DOT-4737] Removed null check for buildName flag and sanity checks for empty string values
2 parents 81581a1 + 2f07e96 commit 015b355

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

commands/storybook.js

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,29 @@ 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}`)
117+
let baseLine = process.env.BASELINE_BRANCH;
118+
let currentBranch = process.env.CURRENT_BRANCH;
119+
if (baseLine !== null && baseLine !== undefined){
120+
if(baseLine === ''){
121+
const error = {
122+
"error": "MISSING_BRANCH_NAME",
123+
"message": "Error : The baseline branch name environment variable cannot be empty."
124+
};
125+
console.log(JSON.stringify(error, null, 2));
126+
process.exit(1);
127+
}
128+
}
129+
130+
if(currentBranch !== null && currentBranch !==undefined){
131+
if(currentBranch === ''){
132+
const error = {
133+
"error": "MISSING_BRANCH_NAME",
134+
"message": "Error : The current branch name environment variable cannot be empty."
135+
};
136+
console.log(JSON.stringify(error, null, 2));
137+
process.exit(1);
138+
}
139+
}
121140
let payload = {
122141
downloadURL: url.substring(url.search(/.com/)+5, url.search(/.zip/)+4),
123142
uploadId: uploadId,
@@ -130,14 +149,14 @@ async function storybook(serve, options) {
130149
customViewports: storybookConfig.customViewports
131150
},
132151
git: {
133-
branch: process.env.BRANCH_NAME ? process.env.BRANCH_NAME: commit.branch,
152+
branch: currentBranch || commit.branch|| '',
153+
baselineBranch: baseLine || '',
134154
commitId: commit.shortHash,
135155
commitAuthor: commit.author.name,
136156
commitMessage: commit.subject,
137157
githubURL: process.env.GITHUB_URL || '',
138158
},
139159
buildName: buildName,
140-
baseline: baseLine?? "",
141160
}
142161

143162
// Call static render API

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ program.command('storybook')
4242
await checkUpdate(version, options);
4343
console.log('\n');
4444
// Check if buildName is undefined or empty string
45-
if (options.buildName === undefined || options.buildName === '') {
45+
if (options.buildName === '') {
4646
const error = {
4747
"error": "MISSING_BUILD_NAME",
4848
"message": "The --buildName flag requires a value."

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lambdatest/smartui-storybook",
3-
"version": "1.1.20",
3+
"version": "1.1.21",
44
"description": "LambdaTest's command-line interface (CLI) aimed to help you run your SmartUI tests on LambdaTest platform",
55
"main": "index.js",
66
"repository": {

0 commit comments

Comments
 (0)