Skip to content

Commit 6c86998

Browse files
committed
fix(cli): support --no-sandbox
1 parent ad30b21 commit 6c86998

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

src/config/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ export default {
139139
alias: 'n',
140140
default: false,
141141
},
142+
sandbox: {
143+
type: 'boolean',
144+
default: true,
145+
},
142146
},
143147

144148
CHROME_LAUNCH_ARGS: [

src/helpers/flags.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,25 @@ const getDefaultOptions = (): Options => {
5454
};
5555

5656
const normalizeSandboxOption = (
57-
noSandbox: boolean | undefined,
57+
options: CLIOptions,
5858
logger: LoggerFunction,
5959
): Partial<Options> => {
6060
let sandboxDisabled = false;
61-
if (noSandbox) {
62-
if (os.platform() !== 'linux') {
63-
logger.warn(
64-
'Disabling sandbox is only relevant on Linux platforms, request declined!',
65-
);
66-
} else {
67-
sandboxDisabled = true;
68-
}
61+
if (options.noSandbox === true) {
62+
sandboxDisabled = true;
63+
}
64+
if (options.sandbox === false) {
65+
sandboxDisabled = true;
66+
}
67+
if (sandboxDisabled && os.platform() !== 'linux') {
68+
logger.warn(
69+
'Disabling sandbox is only relevant on Linux platforms, request declined!',
70+
);
71+
sandboxDisabled = false;
6972
}
7073
return {
7174
noSandbox: sandboxDisabled,
75+
sandbox: !sandboxDisabled,
7276
};
7377
};
7478

src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async function generateImages(
6363
options,
6464
logger,
6565
),
66-
...flags.normalizeSandboxOption(options.noSandbox, logger),
66+
...flags.normalizeSandboxOption(options, logger),
6767
};
6868
} else {
6969
modOptions = {

src/models/options.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ export interface Options {
156156
@default false
157157
*/
158158
readonly noSandbox: boolean;
159+
160+
/**
161+
Enable sandbox on bundled Chromium on Linux platforms - recommended
162+
163+
@default true
164+
*/
165+
readonly sandbox: boolean;
159166
}
160167

161168
export type CLIOptions = Partial<Options>;

0 commit comments

Comments
 (0)