File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 1
- import { join } from "node:path" ;
2
- import { rm } from "node:fs/promises" ;
1
+ import { dirname , join } from "node:path" ;
2
+ import { readFileSync } from "node:fs" ;
3
+ import { readFile , rm } from "node:fs/promises" ;
3
4
import { copy , json , pkg , type Skeleton } from "code-skeleton" ;
5
+
6
+ const ownPkg = JSON . parse (
7
+ readFileSync ( join ( dirname ( __dirname ) , "package.json" ) , { encoding : "utf8" } )
8
+ ) as { name : string ; version : string } ;
4
9
5
10
interface Variables {
6
11
dogfood ?: boolean ;
7
12
library ?: boolean ;
8
13
}
9
14
10
15
export default async function ( root : string , variables : Variables ) {
16
+ const actualContent = await readFile ( join ( root , "package.json" ) , { encoding : "utf8" } ) ;
17
+ const actualPkg = JSON . parse ( actualContent ) as { name : string ; dependencies ?: Record < string , string > } ;
18
+ if ( actualPkg . name !== ownPkg . name && actualPkg . dependencies ?. [ ownPkg . name ] !== ownPkg . version ) {
19
+ console . log ( `ERROR! The dependency "${ ownPkg . name } " must be set to the exact version "${ ownPkg . version } "` ) ;
20
+ console . log ( `Try running \`npm install --save-exact -D ${ ownPkg . name } \`` ) ;
21
+ process . exit ( 1 ) ;
22
+ }
23
+
11
24
const csBin = variables . dogfood ? "./bin/code-skeleton.ts" : "code-skeleton" ;
12
25
const skeleton : Skeleton = {
13
26
"package.json" : pkg ( {
You can’t perform that action at this time.
0 commit comments