Skip to content

Commit 44c6fdb

Browse files
authored
Merge pull request #5 from devicecloud-dev/better-space-handling
Better space handling
2 parents c06d134 + 8d31dab commit 44c6fdb

File tree

4 files changed

+38
-14
lines changed

4 files changed

+38
-14
lines changed

dist/index.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32548,7 +32548,6 @@ const run = () => __awaiter(void 0, void 0, void 0, function* () {
3254832548
async,
3254932549
'device-locale': deviceLocale,
3255032550
'download-artifacts': downloadArtifacts,
32551-
env,
3255232551
'exclude-flows': excludeFlows,
3255332552
'exclude-tags': excludeTags,
3255432553
flows: workspaceFolder,
@@ -32560,9 +32559,24 @@ const run = () => __awaiter(void 0, void 0, void 0, function* () {
3256032559
name,
3256132560
orientation,
3256232561
};
32563-
const paramsString = Object.keys(params).reduce((acc, key) => {
32564-
return params[key] ? `${acc} --${key} "${params[key]}"` : acc;
32562+
let paramsString = Object.keys(params).reduce((acc, key) => {
32563+
if (!params[key])
32564+
return acc;
32565+
const needsQuotes = typeof params[key] === 'string' &&
32566+
'"' !== params[key][0] &&
32567+
params[key].includes(' ');
32568+
const value = needsQuotes ? `"${params[key]}"` : params[key];
32569+
return `${acc} --${key} ${value}`;
3256532570
}, '');
32571+
if (env && env.length > 0) {
32572+
env.forEach((e) => {
32573+
let [key, value] = e.split('=');
32574+
const needsQuotes = '"' !== value[0] && value.includes(' ');
32575+
if (needsQuotes)
32576+
value = `"${value}"`;
32577+
paramsString += ` --env ${key}=${value}`;
32578+
});
32579+
}
3256632580
(0, child_process_1.execSync)(`npx --yes @devicecloud.dev/dcd cloud ${paramsString} --quiet`, {
3256732581
stdio: 'inherit',
3256832582
});
@@ -32745,9 +32759,7 @@ function getParameters() {
3274532759
if (!(appFilePath !== '') !== (appBinaryId !== '')) {
3274632760
throw new Error('Either app-file or app-binary-id must be used');
3274732761
}
32748-
const env = core
32749-
.getMultilineInput('env', { required: false })
32750-
.join(' --env ');
32762+
const env = core.getMultilineInput('env', { required: false });
3275132763
const androidApiLevel = getAndroidApiLevel(androidApiLevelString);
3275232764
const iOSVersion = getIOSVersion(iOSVersionString);
3275332765
return {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "dcd-github-action",
33
"description": "run maestro tests on devicecloud.dev",
44
"author": "devicecloud.dev",
5-
"version": "1.1.0",
5+
"version": "1.1.1",
66
"main": "src/index.ts",
77
"license": "MIT",
88
"engines": {

src/index.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ const run = async (): Promise<void> => {
4141
async,
4242
'device-locale': deviceLocale,
4343
'download-artifacts': downloadArtifacts,
44-
env,
4544
'exclude-flows': excludeFlows,
4645
'exclude-tags': excludeTags,
4746
flows: workspaceFolder,
@@ -54,10 +53,25 @@ const run = async (): Promise<void> => {
5453
orientation,
5554
};
5655

57-
const paramsString = Object.keys(params).reduce((acc, key) => {
58-
return params[key] ? `${acc} --${key} "${params[key]}"` : acc;
56+
let paramsString = Object.keys(params).reduce((acc, key) => {
57+
if (!params[key]) return acc;
58+
const needsQuotes =
59+
typeof params[key] === 'string' &&
60+
'"' !== params[key][0] &&
61+
params[key].includes(' ');
62+
const value = needsQuotes ? `"${params[key]}"` : params[key];
63+
return `${acc} --${key} ${value}`;
5964
}, '');
6065

66+
if (env && env.length > 0) {
67+
env.forEach((e) => {
68+
let [key, value] = e.split('=');
69+
const needsQuotes = '"' !== value[0] && value.includes(' ');
70+
if (needsQuotes) value = `"${value}"`;
71+
paramsString += ` --env ${key}=${value}`;
72+
});
73+
}
74+
6175
execSync(`npx --yes @devicecloud.dev/dcd cloud ${paramsString} --quiet`, {
6276
stdio: 'inherit',
6377
});

src/methods/params.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export type Params = {
66
apiUrl: string;
77
appFilePath: string;
88
workspaceFolder: string | null;
9-
env?: string;
9+
env?: string[];
1010
async?: boolean;
1111
androidApiLevel?: number;
1212
iOSVersion?: number;
@@ -186,9 +186,7 @@ export async function getParameters(): Promise<Params> {
186186
throw new Error('Either app-file or app-binary-id must be used');
187187
}
188188

189-
const env = core
190-
.getMultilineInput('env', { required: false })
191-
.join(' --env ');
189+
const env = core.getMultilineInput('env', { required: false });
192190

193191
const androidApiLevel = getAndroidApiLevel(androidApiLevelString);
194192
const iOSVersion = getIOSVersion(iOSVersionString);

0 commit comments

Comments
 (0)