(options: ZipFactoryParams = {})
| 34 | }; |
| 35 | |
| 36 | const publish = async (options: ZipFactoryParams = {}) => { |
| 37 | const projectToPublish = options.project || project; |
| 38 | if (!projectToPublish) { |
| 39 | throw new PublisherError('MissingProject'); |
| 40 | } |
| 41 | |
| 42 | const zipName = options.projectSlug || params.projectSlug || projectToPublish.name; |
| 43 | |
| 44 | try { |
| 45 | const zipContent = await generateProjectZip(projectToPublish); |
| 46 | |
| 47 | if (isNodeProcess()) { |
| 48 | // If not output path is provided on the node side, zip is not written to disk |
| 49 | const projectOutputPath = options.outputPath || outputPath; |
| 50 | if (projectOutputPath) { |
| 51 | await writeZipToDisk(projectOutputPath, zipContent, zipName); |
| 52 | } |
| 53 | } else { |
| 54 | // the browser end does not require a path |
| 55 | // auto download zip files |
| 56 | saveAs(zipContent as Blob, `${zipName}.zip`); |
| 57 | } |
| 58 | |
| 59 | return { success: true, payload: zipContent }; |
| 60 | } catch (error) { |
| 61 | throw new PublisherError(getErrorMessage(error) || 'UnknownError'); |
| 62 | } |
| 63 | }; |
| 64 | |
| 65 | return { |
| 66 | publish, |
nothing calls this directly
no test coverage detected
searching dependent graphs…