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 Mar 24, 2023
1 parent 71c371d commit af8b5fa
Showing 1 changed file with 2 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,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 af8b5fa

Please sign in to comment.