Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): support --no-sandbox #1018

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ export default {
alias: 'n',
default: false,
},
sandbox: {
type: 'boolean',
alias: 'y',
default: true,
},
},

CHROME_LAUNCH_ARGS: [
Expand Down
22 changes: 13 additions & 9 deletions src/helpers/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,25 @@ const getDefaultOptions = (): Options => {
};

const normalizeSandboxOption = (
noSandbox: boolean | undefined,
options: CLIOptions,
logger: LoggerFunction,
): Partial<Options> => {
let sandboxDisabled = false;
if (noSandbox) {
if (os.platform() !== 'linux') {
logger.warn(
'Disabling sandbox is only relevant on Linux platforms, request declined!',
);
} else {
sandboxDisabled = true;
}
if (options.noSandbox === true) {
sandboxDisabled = true;
}
if (options.sandbox === false) {
sandboxDisabled = true;
}
if (sandboxDisabled && os.platform() !== 'linux') {
logger.warn(
'Disabling sandbox is only relevant on Linux platforms, request declined!',
);
sandboxDisabled = false;
}
return {
noSandbox: sandboxDisabled,
sandbox: !sandboxDisabled,
};
};

Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async function generateImages(
options,
logger,
),
...flags.normalizeSandboxOption(options.noSandbox, logger),
...flags.normalizeSandboxOption(options, logger),
};
} else {
modOptions = {
Expand Down
7 changes: 7 additions & 0 deletions src/models/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ export interface Options {
@default false
*/
readonly noSandbox: boolean;

/**
Enable sandbox on bundled Chromium on Linux platforms - recommended

@default true
*/
readonly sandbox: boolean;
}

export type CLIOptions = Partial<Options>;
Loading