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,CAAC,KAAK,EAAE,EAAE,KAAK;QAC3C,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC;YAClB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;QAClC,CAAC;QACD,IAAI,CAAC,CAAC;YACJ,GAAG,CAAC,CAAC,IAAI,IAAI,IAAI,YAAY,CAAC,CAAC,CAAC;gBAC9B,IAAI,CAAC,MAAM,EAAE,CAAA;YACf,CAAC;YACD,MAAM,CAAC,IAAI,CAAA;QACb,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAnEe,aAAK,QAmEpB,CAAA","sourcesContent":["import { Packager } from \"./packager\"\nimport { PackagerOptions } from \"./platformPackager\"\nimport { PublishOptions, Publisher, GitHubPublisher } from \"./gitHubPublisher\"\nimport { executeFinally } from \"./promise\"\nimport { Promise as BluebirdPromise } from \"bluebird\"\nimport { tsAwaiter } from \"./awaiter\"\nimport { InfoRetriever } from \"./repositoryInfo\"\nimport { log } from \"./util\"\n\nconst __awaiter = tsAwaiter\nArray.isArray(__awaiter)\n\nexport async function createPublisher(packager: Packager, options: BuildOptions, repoSlug: InfoRetriever, isPublishOptionGuessed: boolean = false): Promise<Publisher> {\n const info = await repoSlug.getInfo(packager)\n if (info == null) {\n if (isPublishOptionGuessed) {\n return null\n }\n\n log(\"Cannot detect repository by .git/config\")\n throw new Error(\"Please specify 'repository' in the dev package.json ('\" + packager.devPackageFile + \"')\")\n }\n else {\n return new GitHubPublisher(info.user, info.project, packager.metadata.version, options.githubToken, options.publish !== \"onTagOrDraft\")\n }\n}\n\nexport interface BuildOptions extends PackagerOptions, PublishOptions {\n}\n\nexport function build(options: BuildOptions = {}): Promise<any> {\n if (options.cscLink == null) {\n options.cscLink = process.env.CSC_LINK\n }\n if (options.cscKeyPassword == null) {\n options.cscKeyPassword = process.env.CSC_KEY_PASSWORD\n }\n\n if (options.githubToken == null) {\n options.githubToken = process.env.GH_TOKEN || process.env.GH_TEST_TOKEN\n }\n\n const lifecycleEvent = process.env.npm_lifecycle_event\n if (options.dist === undefined) {\n options.dist = lifecycleEvent === \"dist\" || lifecycleEvent === \"build\"\n }\n\n if (options.publish) {\n options.dist = true\n }\n\n let isPublishOptionGuessed = false\n if (options.publish === undefined) {\n if (lifecycleEvent === \"release\") {\n options.publish = \"always\"\n }\n else {\n const tag = process.env.TRAVIS_TAG || process.env.APPVEYOR_REPO_TAG_NAME || process.env.CIRCLE_TAG\n if (tag != null && tag.length !== 0) {\n log(\"Tag %s is defined, so artifacts will be published\", tag)\n options.publish = \"onTag\"\n isPublishOptionGuessed = true\n }\n else if ((process.env.TRAVIS || process.env.APPVEYOR || process.env.CIRCLECI || \"\").toLowerCase() === \"true\") {\n log(\"CI detected, so artifacts will be published if draft release exists\")\n options.publish = \"onTagOrDraft\"\n isPublishOptionGuessed = true\n }\n }\n }\n\n const publishTasks: Array<BluebirdPromise<any>> = []\n const repositoryInfo = new InfoRetriever()\n const packager = new Packager(options, repositoryInfo)\n if (options.publish != null && options.publish !== \"never\") {\n let publisher: BluebirdPromise<Publisher> = null\n packager.artifactCreated(path => {\n if (publisher == null) {\n publisher = <BluebirdPromise<Publisher>>createPublisher(packager, options, repositoryInfo, isPublishOptionGuessed)\n }\n\n if (publisher != null) {\n publisher.then(it => publishTasks.push(<BluebirdPromise<any>>it.upload(path)))\n }\n })\n }\n return executeFinally(packager.build(), error => {\n if (error == null) {\n return Promise.all(publishTasks)\n }\n else {\n for (let task of publishTasks) {\n task.cancel()\n }\n return null\n }\n })\n}"]} |