File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
packages/create-project/src/helpers Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { readFile, writeFile } from 'node:fs/promises';
3
3
4
4
import { spawn } from './subprocess.js' ;
5
5
import { isUrlOk } from './samples.js' ;
6
+ import { getErrorCode } from './get-error-code.js' ;
6
7
7
8
interface InstallArgs {
8
9
root : string ;
@@ -45,8 +46,18 @@ export async function updateNodeVersion({ root }: InstallArgs): Promise<void> {
45
46
await writeFile ( fileName , fileString . replace ( `@tsconfig/node${ versionAlreadyInPackageJson } ` , packageName ) ) ;
46
47
47
48
const tsconfigJson = `${ root } /tsconfig.json` ;
48
- fileString = ( await readFile ( tsconfigJson ) ) . toString ( ) ;
49
- await writeFile ( tsconfigJson , fileString . replace ( `@tsconfig/node${ versionAlreadyInPackageJson } ` , packageName ) ) ;
49
+
50
+ try {
51
+ fileString = ( await readFile ( tsconfigJson ) ) . toString ( ) ;
52
+ await writeFile ( tsconfigJson , fileString . replace ( `@tsconfig/node${ versionAlreadyInPackageJson } ` , packageName ) ) ;
53
+ } catch ( error ) {
54
+ const code = getErrorCode ( error ) ;
55
+
56
+ // If the file doesn't exist, that's fine
57
+ if ( code !== 'ENOENT' ) {
58
+ throw error ;
59
+ }
60
+ }
50
61
}
51
62
52
63
await writeFile ( `${ root } /.nvmrc` , currentNodeVersion . toString ( ) ) ;
You can’t perform that action at this time.
0 commit comments