(config)
| 32 | }; |
| 33 | |
| 34 | export default async function run(config) { |
| 35 | console.assert( |
| 36 | (await exec('echo "hello world"').then((r) => r.stdout?.trim())) == |
| 37 | "hello world", |
| 38 | ); |
| 39 | config = { |
| 40 | outputsPath: "outputs/profile", |
| 41 | ...config, |
| 42 | }; |
| 43 | |
| 44 | if (existsSync(config.outputsPath)) { |
| 45 | console.error("Outputs path already exists"); |
| 46 | process.exit(1); |
| 47 | } |
| 48 | |
| 49 | const profilePath = resolve(config.outputsPath); |
| 50 | |
| 51 | if (config.extendProfile) { |
| 52 | config.extendProfile.path = config.extendProfile.path.replace( |
| 53 | /^\~/, |
| 54 | homedir(), |
| 55 | ); |
| 56 | const path = resolve(config.extendProfile.path); |
| 57 | if (config.extendProfile.bookmarks && config.extendProfile.history) { |
| 58 | copyFilesToProfile(profilePath, [resolve(path, "places.sqlite")]); |
| 59 | } |
| 60 | if (config.extendProfile.passwords) { |
| 61 | copyFilesToProfile(profilePath, [resolve(path, "logins.json")]); |
| 62 | } |
| 63 | if (config.extendProfile.cookies) { |
| 64 | copyFilesToProfile(profilePath, [ |
| 65 | resolve(path, "cookies.sqlite"), |
| 66 | resolve(path, "cookies.sqlite-wal"), |
| 67 | ]); |
| 68 | } |
| 69 | if (config.extendProfile.extensions) { |
| 70 | copyFilesToProfile(profilePath, [ |
| 71 | resolve(path, "extension-preferences.json"), |
| 72 | resolve(path, "extension-settings.json"), |
| 73 | ]); |
| 74 | cpSync(resolve(path, "extensions"), resolve(profilePath, "extensions"), { |
| 75 | recursive: true, |
| 76 | }); |
| 77 | cpSync( |
| 78 | resolve(path, "extension-store"), |
| 79 | resolve(profilePath, "extension-store"), |
| 80 | { |
| 81 | recursive: true, |
| 82 | }, |
| 83 | ); |
| 84 | cpSync( |
| 85 | resolve(path, "extension-store-menus"), |
| 86 | resolve(profilePath, "extension-store-menus"), |
| 87 | { |
| 88 | recursive: true, |
| 89 | }, |
| 90 | ); |
| 91 | for (let ext of readdirSync(resolve(path, "storage", "default")).filter( |
no test coverage detected