Gracefully handle non-absolute path for create-login-profile --filename (#521)

Fixes #513 

If an absolute path isn't provided to the `create-login-profile`
entrypoint's `--filename` option, resolve the value given within
`/crawls/profiles`.

Also updates the docs cli-options section to include the
`create-login-profile` entrypoint and adjusts the script to
automatically generate this page accordingly.

---------
Co-authored-by: Ilya Kreymer <ikreymer@gmail.com>
This commit is contained in:
Tessa Walsh 2024-03-29 16:46:54 -04:00 committed by GitHub
parent 5152169916
commit 1325cc3868
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 79 additions and 14 deletions

View file

@ -52,7 +52,8 @@ function cliOpts(): { [key: string]: Options } {
},
filename: {
describe: "The filename for the profile tarball",
describe:
"The filename for the profile tarball, stored within /crawls/profiles if absolute path not provided",
default: "/crawls/profiles/profile.tar.gz",
},
@ -300,6 +301,13 @@ async function createProfile(
logger.info("Creating profile");
if (params.filename && !params.filename.startsWith("/")) {
params.filename = path.resolve("/crawls/profiles/", params.filename);
logger.info(
`Absolute path for filename not provided, saving to ${params.filename}`,
);
}
const profileFilename = params.filename || "/crawls/profiles/profile.tar.gz";
const outputDir = path.dirname(profileFilename);