diff --git a/packages/js/src/executors/node/node.impl.ts b/packages/js/src/executors/node/node.impl.ts index 05bc93924c02e5..ad7f60a99d42e8 100644 --- a/packages/js/src/executors/node/node.impl.ts +++ b/packages/js/src/executors/node/node.impl.ts @@ -74,15 +74,10 @@ export async function* nodeExecutor( // Re-map buildable workspace projects to their output directory. const mappings = calculateResolveMappings(context, options); - const outputFileNameWithoutExtension = - buildOptions.outputFileName ?? path.parse(buildOptions.main).name; - - const fileToRun = getOutputFilePath( - context.root, - buildOptions.outputPath, - outputFileNameWithoutExtension - ); + const outputFileName = + buildOptions.outputFileName ?? `${path.parse(buildOptions.main).name}.js`; + const fileToRun = join(context.root, buildOptions.outputPath, outputFileName); const tasks: ActiveTask[] = []; let currentTask: ActiveTask = null; @@ -311,35 +306,4 @@ function runWaitUntilTargets( ); } -function getOutputFilePath( - root: string, - outputPath: string, - outputFileNameWithoutExtension: string -): string { - const possibleExtensions = ['.js', '.cjs', '.mjs']; - let fullPath: string | undefined = undefined; - - for (const extension of possibleExtensions) { - const filePath = join( - root, - outputPath, - `${outputFileNameWithoutExtension}${extension}` - ); - - if (fileExists(filePath)) { - fullPath = filePath; - break; - } - } - - if (!fullPath) { - throw new Error( - `Could not find any output files for ${outputFileNameWithoutExtension} in ${outputPath}, - please try building the project first, or make sure your build ran correctly.` - ); - } - - return fullPath; -} - export default nodeExecutor;