File tree Expand file tree Collapse file tree 2 files changed +8
-12
lines changed Expand file tree Collapse file tree 2 files changed +8
-12
lines changed Original file line number Diff line number Diff line change 1
- import fs from "node:fs/promises" ;
2
- import path from "node:path" ;
3
-
4
- const packageJsonFilePath = path . join ( __dirname , "../../package.json" ) ;
1
+ import { PackageSettings } from "../lib/package-settings" ;
5
2
6
3
export const version = async ( ) => {
7
- const data = await fs . readFile ( packageJsonFilePath , { encoding : "utf8" } ) ;
8
- const { version } = JSON . parse ( data ) ;
9
-
10
- if ( ! version ) {
11
- throw new Error ( "Error: version is not found" ) ;
12
- }
13
-
14
- console . log ( version ) ;
4
+ console . log ( PackageSettings . version ) ;
15
5
} ;
Original file line number Diff line number Diff line change
1
+ const packageJsonData = require ( "../../package.json" ) ;
2
+
3
+ export const PackageSettings = {
4
+ userAgentName : "QiitaCLI" ,
5
+ version : packageJsonData . version ,
6
+ } ;
You can’t perform that action at this time.
0 commit comments