Skip to content

Commit 93f0de1

Browse files
committed
fix: update shell command built from environment values with additional improvements
1 parent c09364f commit 93f0de1

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

packages/ui-mobile-visreg/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
"@percy/cli": "^1.31.1",
4747
"@percy/client": "^1.31.1",
4848
"@percy/sdk-utils": "^1.31.1",
49-
"lodash": "^4.17.21"
49+
"lodash": "^4.17.21",
50+
"shell-quote": "^1.8.3"
5051
},
5152
"devDependencies": {
5253
"@babel/core": "^7.28.0",

packages/ui-mobile-visreg/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/// <reference types="detox" />
22

33
import { execSync } from 'node:child_process';
4+
import shellQuote from 'shell-quote';
45

56
import type { PercyScreenshotOptions } from './percy/processScreenshots';
67
import processScreenshots from './percy/processScreenshots';
@@ -111,8 +112,9 @@ export function processScreenshotsForVisualDiffs(options: {
111112
}) {
112113
const screenshotsDir = options.screenshotsDir ? `/${options.screenshotsDir}` : '';
113114
const fullDirPath = `${baseDir}${screenshotsDir}`;
115+
const quotedDirPath = shellQuote.quote([fullDirPath]);
114116

115-
processScreenshots(fullDirPath, options.processingOptions ?? {});
117+
processScreenshots(quotedDirPath, options.processingOptions ?? {});
116118
}
117119

118120
/**

packages/ui-mobile-visreg/src/percy/processScreenshots.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { runCmd } from '../utils';
1+
import { runCmd } from '../utils';
2+
import shellQuote from 'shell-quote';
23

34
export type PercyScreenshotOptions = {
45
skipPercyUpload?: boolean;
56
parallelPercy?: boolean;
67
};
78

89
function uploadImages(dirPath: string, parallelPercy = false) {
9-
const percyUploadCmd = `percy upload -c ./.percy.yml -f "./*.{png,jpg,jpeg}" ${dirPath}`;
10+
const safeDirPath = shellQuote.quote([dirPath]);
11+
const percyUploadCmd = `percy upload -c ./.percy.yml -f "./*.{png,jpg,jpeg}" ${safeDirPath}`;
1012
const cmd = parallelPercy ? `percy exec --parallel -- ${percyUploadCmd}` : percyUploadCmd;
1113
runCmd(cmd);
1214
}
@@ -19,3 +21,4 @@ export default function processScreenshots(
1921
uploadImages(dirPath, parallelPercy);
2022
}
2123
}
24+

0 commit comments

Comments
 (0)