From 09bc25558c7926ddaa81303984f46615c5ce01c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20=C5=BDia=C4=8Dik?= Date: Sun, 23 Jul 2023 16:55:05 +0200 Subject: [PATCH] fix(upgrade-verify): isolate builds from env and context changes --- packages/upgrade-verify/CHANGELOG.md | 9 ++++- packages/upgrade-verify/package.json | 2 +- .../_dist/test-app/3rdpartylicenses.txt | 2 + .../_dist/test-app/assets/.gitkeep | 0 .../__fixtures__/_dist/test-app/favicon.ico | Bin 0 -> 15086 bytes .../__fixtures__/_dist/test-app/index.html | 13 ++++++ .../_dist/test-app/main.0274b0362ab850a9.css | 1 + .../_dist/test-app/main.3d931a8f6ad8b28f.js | 1 + .../test-app/runtime.dd97139be5136261.js | 1 + .../_dist/test-app/styles.91b7890a3e13c303.js | 1 + .../test-app/styles.ef46db3751d8e999.css | 0 .../executors/verify-build/executor.spec.ts | 38 +++++++++++++++++- .../src/executors/verify-build/executor.ts | 18 +++++++-- 13 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/3rdpartylicenses.txt create mode 100644 packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/assets/.gitkeep create mode 100644 packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/favicon.ico create mode 100644 packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/index.html create mode 100644 packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/main.0274b0362ab850a9.css create mode 100644 packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/main.3d931a8f6ad8b28f.js create mode 100644 packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/runtime.dd97139be5136261.js create mode 100644 packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/styles.91b7890a3e13c303.js create mode 100644 packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/styles.ef46db3751d8e999.css diff --git a/packages/upgrade-verify/CHANGELOG.md b/packages/upgrade-verify/CHANGELOG.md index 37a0fc3..3cc22f2 100644 --- a/packages/upgrade-verify/CHANGELOG.md +++ b/packages/upgrade-verify/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.0.3] - 2023-07-23 + +### Fixed + +- Build runs are now isolated from ExecutorContext and process.env changes so that they do not interfere with each other. + ## [0.0.2] - 2023-07-07 ### Changed @@ -14,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - READMEs updated and props added to package.json. - A _Package subpath './package.json' is not defined by "exports"_ error hopefully fixed. -[unreleased]: https://github.com/ziacik/nx-tools/compare/upgrade-verify-0.0.2...HEAD +[unreleased]: https://github.com/ziacik/nx-tools/compare/upgrade-verify-0.0.3...HEAD +[0.0.3]: https://github.com/ziacik/nx-tools/compare/upgrade-verify-0.0.2...upgrade-verify-0.0.3 [0.0.2]: https://github.com/ziacik/nx-tools/compare/upgrade-verify-0.0.1...upgrade-verify-0.0.2 [0.0.1]: https://github.com/ziacik/nx-tools/releases/tag/upgrade-verify-0.0.1 diff --git a/packages/upgrade-verify/package.json b/packages/upgrade-verify/package.json index bcbbf66..f444bc7 100644 --- a/packages/upgrade-verify/package.json +++ b/packages/upgrade-verify/package.json @@ -1,6 +1,6 @@ { "name": "@ziacik/upgrade-verify", - "version": "0.0.2", + "version": "0.0.3", "type": "commonjs", "executors": "./executors.json", "keywords": [ diff --git a/packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/3rdpartylicenses.txt b/packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/3rdpartylicenses.txt new file mode 100644 index 0000000..a9fe774 --- /dev/null +++ b/packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/3rdpartylicenses.txt @@ -0,0 +1,2 @@ +@ziacik/source +MIT diff --git a/packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/assets/.gitkeep b/packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/assets/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/favicon.ico b/packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..317ebcb2336e0833a22dddf0ab287849f26fda57 GIT binary patch literal 15086 zcmeI332;U^%p|z7g|#(P)qFEA@4f!_@qOK2 z_lJl}!lhL!VT_U|uN7%8B2iKH??xhDa;*`g{yjTFWHvXn;2s{4R7kH|pKGdy(7z!K zgftM+Ku7~24TLlh(!g)gz|foI94G^t2^IO$uvX$3(OR0<_5L2sB)lMAMy|+`xodJ{ z_Uh_1m)~h?a;2W{dmhM;u!YGo=)OdmId_B<%^V^{ovI@y`7^g1_V9G}*f# zNzAtvou}I!W1#{M^@ROc(BZ! z+F!!_aR&Px3_reO(EW+TwlW~tv*2zr?iP7(d~a~yA|@*a89IUke+c472NXM0wiX{- zl`UrZC^1XYyf%1u)-Y)jj9;MZ!SLfd2Hl?o|80Su%Z?To_=^g_Jt0oa#CT*tjx>BI z16wec&AOWNK<#i0Qd=1O$fymLRoUR*%;h@*@v7}wApDl^w*h}!sYq%kw+DKDY)@&A z@9$ULEB3qkR#85`lb8#WZw=@})#kQig9oqy^I$dj&k4jU&^2(M3q{n1AKeGUKPFbr z1^<)aH;VsG@J|B&l>UtU#Ejv3GIqERzYgL@UOAWtW<{p#zy`WyJgpCy8$c_e%wYJL zyGHRRx38)HyjU3y{-4z6)pzb>&Q1pR)B&u01F-|&Gx4EZWK$nkUkOI|(D4UHOXg_- zw{OBf!oWQUn)Pe(=f=nt=zkmdjpO^o8ZZ9o_|4tW1ni+Un9iCW47*-ut$KQOww!;u z`0q)$s6IZO!~9$e_P9X!hqLxu`fpcL|2f^I5d4*a@Dq28;@2271v_N+5HqYZ>x;&O z05*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ade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/main.0274b0362ab850a9.css b/packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/main.0274b0362ab850a9.css new file mode 100644 index 0000000..caf27a7 --- /dev/null +++ b/packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/main.0274b0362ab850a9.css @@ -0,0 +1 @@ +html{-webkit-text-size-adjust:100%;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;line-height:1.5;scroll-behavior:smooth;-moz-tab-size:4;-o-tab-size:4;tab-size:4}body{font-family:inherit;line-height:inherit}body,h1,h2,p,pre{margin:0}*,:after,:before{border:0 solid;box-sizing:border-box}h1,h2{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}svg{shape-rendering:auto;display:block;text-rendering:optimizeLegibility;vertical-align:middle}pre{background-color:#374151;border-radius:.25rem;color:#e5e7eb;font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;overflow:scroll;padding:.5rem .75rem}.shadow{box-shadow:0 0 #0000,0 0 #0000,0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -2px rgba(0,0,0,.05)}.rounded{border-radius:1.5rem}.wrapper{width:100%}.container{color:#374151;margin-left:auto;margin-right:auto;max-width:768px;padding-bottom:3rem;padding-left:1rem;padding-right:1rem;width:100%}#welcome{margin-top:2.5rem}#welcome h1{font-size:3rem;font-weight:500;letter-spacing:-.025em;line-height:1}#welcome span{display:block;font-size:1.875rem;font-weight:300;line-height:2.25rem;margin-bottom:.5rem}#hero{align-items:center;background-color:#143157;border:none;box-sizing:border-box;color:#374151;display:grid;grid-template-columns:1fr;margin-top:3.5rem}#hero .text-container{color:#fff;padding:3rem 2rem}#hero .text-container h2{font-size:1.5rem;line-height:2rem;position:relative}#hero .text-container h2 svg{color:#44bb97;height:2rem;left:-.25rem;position:absolute;top:0;width:2rem}#hero .text-container h2 span{margin-left:2.5rem}#hero .text-container a{background-color:#fff;border-radius:.75rem;color:#374151;display:inline-block;margin-top:1.5rem;padding:1rem 2rem;text-decoration:inherit}#hero .logo-container{display:none;justify-content:center;padding-left:2rem;padding-right:2rem}#hero .logo-container svg{color:#fff;width:66.666667%}#middle-content{align-items:flex-start;display:grid;gap:4rem;grid-template-columns:1fr;margin-top:3.5rem}#learning-materials{padding:2.5rem 2rem}#learning-materials h2{font-size:1.25rem;font-weight:500;letter-spacing:-.025em;line-height:1.75rem;padding-left:1rem;padding-right:1rem}.list-item-link{align-items:center;border-radius:.75rem;display:flex;margin-top:1rem;padding:1rem;width:100%}.list-item-link,.list-item-link svg:first-child{transition-duration:.15s;transition-property:background-color,border-color,color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.list-item-link svg:first-child{height:1.5rem;margin-right:1rem;width:1.5rem}.list-item-link>span{font-weight:400}.list-item-link>span,.list-item-link>span>span{flex-grow:1;transition-duration:.15s;transition-property:background-color,border-color,color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.list-item-link>span>span{color:#6b7280;display:block;font-size:.75rem;font-weight:300;line-height:1rem}.list-item-link svg:last-child{height:1rem;transition-duration:.15s;transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);width:1rem}.list-item-link:hover{background-color:#44bb97;color:#fff}.list-item-link:hover>span>span{color:#f3f4f6}.list-item-link:hover svg:last-child{transform:translateX(.25rem)}.button-pill{align-items:center;display:flex;padding:1.5rem 2rem;transition-duration:.3s}.button-pill,.button-pill svg{transition-property:background-color,border-color,color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}.button-pill svg{flex-shrink:0;transition-duration:.15s;width:3rem}.button-pill>span{font-size:1.125rem;font-weight:400;letter-spacing:-.025em;line-height:1.75rem;padding-left:1rem;padding-right:1rem}.button-pill span span{display:block;font-size:.875rem;font-weight:300;line-height:1.25rem}.button-pill:hover,.button-pill:hover svg{color:#fff!important}#nx-console:hover{background-color:#007acc}#nx-console svg{color:#007acc}#nx-repo:hover{background-color:#181717}#nx-repo svg{color:#181717}#nx-cloud{margin-bottom:2rem;margin-top:2rem;padding:2.5rem 2rem}#nx-cloud>div{align-items:center;display:flex}#nx-cloud>div svg{border-radius:.375rem;flex-shrink:0;width:3rem}#nx-cloud>div h2{font-size:1.125rem;font-weight:400;letter-spacing:-.025em;line-height:1.75rem;padding-left:1rem;padding-right:1rem}#nx-cloud>div h2 span{display:block;font-size:.875rem;font-weight:300;line-height:1.25rem}#nx-cloud p{font-size:1rem;line-height:1.5rem}#nx-cloud p,#nx-cloud pre{margin-top:1rem}#nx-cloud a{color:#6b7280;display:block;font-size:.875rem;line-height:1.25rem;margin-top:1.5rem;text-align:right}#nx-cloud a:hover{text-decoration:underline}#commands{margin-top:3.5rem;padding:2.5rem 2rem}#commands h2{font-size:1.25rem;font-weight:400;letter-spacing:-.025em;line-height:1.75rem;padding-left:1rem;padding-right:1rem}#commands p{font-size:1rem;font-weight:300;line-height:1.5rem}#commands p,details{margin-top:1rem;padding-left:1rem;padding-right:1rem}details{align-items:center;display:flex;width:100%}details pre>span{color:#b5b5b5}summary{border-radius:.5rem;cursor:pointer;display:flex;font-weight:400;padding:.5rem;transition-duration:.15s;transition-property:background-color,border-color,color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}summary:hover{background-color:#f3f4f6}summary svg{height:1.5rem;margin-right:1rem;width:1.5rem}#love{color:#6b7280;font-size:.875rem;line-height:1.25rem;margin-top:3.5rem;opacity:.6;text-align:center}#love svg{color:#fca5a5;display:inline;height:1.25rem;margin-top:-.25rem;width:1.25rem}@media screen and (min-width:768px){#hero{grid-template-columns:repeat(2,minmax(0,1fr))}#hero .logo-container{display:flex}#middle-content{grid-template-columns:repeat(2,minmax(0,1fr))}} \ No newline at end of file diff --git a/packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/main.3d931a8f6ad8b28f.js b/packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/main.3d931a8f6ad8b28f.js new file mode 100644 index 0000000..9112339 --- /dev/null +++ b/packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/main.3d931a8f6ad8b28f.js @@ -0,0 +1 @@ +"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[179],{97:()=>{function _construct(Parent,args,Class){return(_construct=_is_native_reflect_construct()?Reflect.construct:function(Parent,args,Class){var a=[null];a.push.apply(a,args);var instance=new(Function.bind.apply(Parent,a));return Class&&_set_prototype_of(instance,Class.prototype),instance}).apply(null,arguments)}function _get_prototype_of(o){return(_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function(o){return o.__proto__||Object.getPrototypeOf(o)})(o)}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw TypeError("Super expression must either be null or a function");subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:!0,configurable:!0}}),superClass&&_set_prototype_of(subClass,superClass)}function _is_native_function(fn){return -1!==Function.toString.call(fn).indexOf("[native code]")}function _set_prototype_of(o,p){return(_set_prototype_of=Object.setPrototypeOf||function(o,p){return o.__proto__=p,o})(o,p)}function _wrap_native_super(Class){var _cache="function"==typeof Map?new Map:void 0;return(_wrap_native_super=function(Class){if(null===Class||!_is_native_function(Class))return Class;if("function"!=typeof Class)throw TypeError("Super expression must either be null or a function");if(void 0!==_cache){if(_cache.has(Class))return _cache.get(Class);_cache.set(Class,Wrapper)}function Wrapper(){return _construct(Class,arguments,_get_prototype_of(this).constructor)}return Wrapper.prototype=Object.create(Class.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),_set_prototype_of(Wrapper,Class)})(Class)}function _is_native_reflect_construct(){if("undefined"==typeof Reflect||!Reflect.construct||Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}var AppElement=function(HTMLElement1){function AppElement(){return HTMLElement1.apply(this,arguments)}return _inherits(AppElement,HTMLElement1),AppElement.prototype.connectedCallback=function(){this.innerHTML='\n
\n
\n \n
\n

\n Hello there, \n Welcome test-app \uD83D\uDC4B\n

\n
\n\n \n
\n
\n

\n \n \n \n You're up and running\n

\n What's next? \n
\n
\n \n \n \n
\n
\n\n \n \n\n \n
\n

Next steps

\n

Here are some things you can do with Nx:

\n
\n \n \n \n \n Add UI library\n \n
# Generate UI lib\nnx g @nx/angular:lib ui\n\n# Add a component\nnx g @nx/angular:component button --project ui
\n
\n
\n \n \n \n \n View interactive project graph\n \n
nx graph
\n
\n
\n \n \n \n \n Run affected commands\n \n
# see what's been affected by changes\nnx affected:graph\n\n# run tests for current changes\nnx affected:test\n\n# run e2e tests for current changes\nnx affected:e2e
\n
\n
\n\n

\n Carefully crafted with\n \n \n \n

\n
\n
\n '},AppElement}(_wrap_native_super(HTMLElement));AppElement.observedAttributes=[],customElements.define("app-root",AppElement)}},__webpack_require__=>{var __webpack_exports__=__webpack_require__(__webpack_require__.s=97)}]); \ No newline at end of file diff --git a/packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/runtime.dd97139be5136261.js b/packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/runtime.dd97139be5136261.js new file mode 100644 index 0000000..d2adc61 --- /dev/null +++ b/packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/runtime.dd97139be5136261.js @@ -0,0 +1 @@ +(()=>{"use strict";var __webpack_modules__={},__webpack_module_cache__={};function __webpack_require__(moduleId){var cachedModule=__webpack_module_cache__[moduleId];if(void 0!==cachedModule)return cachedModule.exports;var module=__webpack_module_cache__[moduleId]={exports:{}};return __webpack_modules__[moduleId](module,module.exports,__webpack_require__),module.exports}__webpack_require__.m=__webpack_modules__,(()=>{var deferred=[];__webpack_require__.O=(result,chunkIds,fn,priority)=>{if(chunkIds){priority=priority||0;for(var i=deferred.length;i>0&&deferred[i-1][2]>priority;i--)deferred[i]=deferred[i-1];deferred[i]=[chunkIds,fn,priority];return}for(var notFulfilled=1/0,i=0;i=priority&&Object.keys(__webpack_require__.O).every(key=>__webpack_require__.O[key](chunkIds[j]))?chunkIds.splice(j--,1):(fulfilled=!1,priorityObject.prototype.hasOwnProperty.call(obj,prop),(()=>{var installedChunks={666:0};__webpack_require__.O.j=chunkId=>0===installedChunks[chunkId];var webpackJsonpCallback=(parentChunkLoadingFunction,data)=>{var moduleId,chunkId,[chunkIds,moreModules,runtime]=data,i=0;if(chunkIds.some(id=>0!==installedChunks[id])){for(moduleId in moreModules)__webpack_require__.o(moreModules,moduleId)&&(__webpack_require__.m[moduleId]=moreModules[moduleId]);if(runtime)var result=runtime(__webpack_require__)}for(parentChunkLoadingFunction&&parentChunkLoadingFunction(data);i{}},__webpack_require__=>{var __webpack_exports__=__webpack_require__(__webpack_require__.s=658)}]); \ No newline at end of file diff --git a/packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/styles.ef46db3751d8e999.css b/packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app/styles.ef46db3751d8e999.css new file mode 100644 index 0000000..e69de29 diff --git a/packages/upgrade-verify/src/executors/verify-build/executor.spec.ts b/packages/upgrade-verify/src/executors/verify-build/executor.spec.ts index 28dfcd8..a0590e8 100644 --- a/packages/upgrade-verify/src/executors/verify-build/executor.spec.ts +++ b/packages/upgrade-verify/src/executors/verify-build/executor.spec.ts @@ -23,7 +23,7 @@ describe('VerifyBuild Executor', () => { yield { success: true, options: { - outputPath: resolve(__dirname, '__fixtures__/dist/test-app'), + outputPath: resolve(__dirname, '__fixtures__/_dist/test-app'), }, }; })() @@ -119,6 +119,40 @@ describe('VerifyBuild Executor', () => { expect(readFile).not.toHaveBeenCalled(); expect(writeFile).not.toHaveBeenCalled(); }); + + it('isolates build runs from executor context modifications', async () => { + jest.spyOn(devkit, 'runExecutor').mockImplementation(async (targetDescription, overrides, context) => { + if (context.target?.command === 'should-not-retain-this') { + throw new Error('Context is modified from previous run.'); + } + context.target ??= {}; + context.target.command = 'should-not-retain-this'; + return (async function* () { + yield { success: true }; + })(); + }); + context.target = { command: 'whatever' }; + const { success } = await executor(options, context); + expect(success).toBe(true); + }); + + it('isolates build runs from process env modifications (but retains the originals)', async () => { + jest.spyOn(devkit, 'runExecutor').mockImplementation(async (targetDescription, overrides, context) => { + if (process.env['something'] === 'should-not-retain-this') { + throw new Error('Env is modified from previous run.'); + } + if (process.env['andThis'] !== 'should-be-retained') { + throw new Error('Env var has not been retained between runs.'); + } + process.env['something'] = 'should-not-retain-this'; + return (async function* () { + yield { success: true }; + })(); + }); + process.env['andThis'] = 'should-be-retained'; + const { success } = await executor(options, context); + expect(success).toBe(true); + }); }); function createContext(): ExecutorContext { @@ -135,7 +169,7 @@ function createContext(): ExecutorContext { targets: { build: { options: { - outputPath: 'packages/upgrade-verify/src/executors/verify-build/__fixtures__/dist/test-app', + outputPath: 'packages/upgrade-verify/src/executors/verify-build/__fixtures__/_dist/test-app', }, configurations: { production: {}, diff --git a/packages/upgrade-verify/src/executors/verify-build/executor.ts b/packages/upgrade-verify/src/executors/verify-build/executor.ts index a60303d..56d1c4b 100644 --- a/packages/upgrade-verify/src/executors/verify-build/executor.ts +++ b/packages/upgrade-verify/src/executors/verify-build/executor.ts @@ -1,6 +1,7 @@ import { ExecutorContext, logger, runExecutor } from '@nx/devkit'; import { mkdir, writeFile } from 'fs/promises'; import { join } from 'path'; +import { env } from 'process'; import { compareStats } from './dist-stat-comparer'; import { calculateDistStats, loadExistingDistStats } from './dist-stats'; import { VerifyBuildExecutorSchema } from './schema'; @@ -29,16 +30,20 @@ export default async function verifyBuild(options: VerifyBuildExecutorSchema, co } let success = true; + const envBackup = { ...env }; for (const configurationName of Object.keys(projectConfig.targets['build'].configurations)) { + retainEnv(envBackup); + const runContext: ExecutorContext = JSON.parse(JSON.stringify(context)); + const result = await runExecutor( { - project: context.projectName, + project: runContext.projectName ?? '', target: 'build', configuration: configurationName, }, {}, - context + runContext ); for await (const x of result) { @@ -56,7 +61,7 @@ export default async function verifyBuild(options: VerifyBuildExecutorSchema, co if (existingStats != null) { const comparison = compareStats(existingStats, newStats); logger.info( - `Stats for ${context.projectName}/${configurationName}: ${comparison.totalSizeDifferencePercentage}% total size difference, ${comparison.fileCountDifferencePercentage}% file count difference, ${comparison.newFilesPercentage}% new files, ${comparison.deletedFilesPercentage}% deleted files` + `Stats for ${runContext.projectName}/${configurationName}: ${comparison.totalSizeDifferencePercentage}% total size difference, ${comparison.fileCountDifferencePercentage}% file count difference, ${comparison.newFilesPercentage}% new files, ${comparison.deletedFilesPercentage}% deleted files` ); if ( @@ -80,3 +85,10 @@ async function tryMkdir(statsDir: string) { // ignore } } + +function retainEnv(envBackup: Record): void { + for (const key of Object.keys(env)) { + delete env[key]; + } + Object.assign(env, envBackup); +}