Skip to content

Commit

Permalink
Use build script to build custom resources #11889
Browse files Browse the repository at this point in the history
…rather than invoking tsc directly from the node_modules/.bin directory
  • Loading branch information
acusti committed Feb 7, 2023
1 parent 4b3db16 commit 14a4d8e
Showing 1 changed file with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,14 @@ const buildResource = async (resource: ResourceMeta): Promise<void> => {
}
}

// 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;
}

Expand Down

0 comments on commit 14a4d8e

Please sign in to comment.