From af8b5fa2f7c042f0f23078114fc69fd18e93e472 Mon Sep 17 00:00:00 2001 From: Andrew Patton Date: Wed, 25 Jan 2023 10:46:29 -0800 Subject: [PATCH] Use build script to build custom resources #11889 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …rather than invoking tsc directly from the node_modules/.bin directory --- .../src/utils/build-custom-resources.ts | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/packages/amplify-category-custom/src/utils/build-custom-resources.ts b/packages/amplify-category-custom/src/utils/build-custom-resources.ts index 74be576f32c..c759b3c03a0 100644 --- a/packages/amplify-category-custom/src/utils/build-custom-resources.ts +++ b/packages/amplify-category-custom/src/utils/build-custom-resources.ts @@ -85,25 +85,14 @@ const buildResource = async (resource: ResourceMeta): Promise => { } } - // get locally installed tsc executable - - const localTscExecutablePath = path.join(targetDir, 'node_modules', '.bin', 'tsc'); - - if (!fs.existsSync(localTscExecutablePath)) { - throw new AmplifyError('MissingOverridesInstallationRequirementsError', { - message: 'TypeScript executable not found.', - resolution: 'Please add it as a dev-dependency in the package.json file for this resource.', - }); - } - try { - execa.sync(localTscExecutablePath, { + execa.sync(packageManager.executable, ['run', 'build'], { cwd: targetDir, stdio: 'pipe', encoding: 'utf-8', }); } catch (error: $TSAny) { - printer.error(`Failed building resource ${resource.resourceName}`); + printer.error(`Failed building resource ${resource.resourceName} with TypeScript`); throw error; }