File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,18 @@ const getProjectRoot = () => {
2727 }
2828}
2929
30+ const getFilePath = ( rootPath , fileName ) => {
31+ let result
32+
33+ result = path . join ( rootPath , fileName )
34+ if ( fs . existsSync ( result ) ) return result
35+
36+ result = path . join ( process . env . HOME , fileName )
37+ if ( fs . existsSync ( result ) ) return result
38+
39+ throw new Error ( `Not found '${ fileName } '.` )
40+ }
41+
3042const loadDefinitions = ( path ) => {
3143 return yaml . safeLoad ( fs . readFileSync ( path , 'utf8' ) )
3244}
6678 } else {
6779 const projectRoot = getProjectRoot ( )
6880 const rootPath = projectRoot === "" ? process . env . HOME : projectRoot
69- const templateFilePath = path . join ( rootPath , templateFileName )
70- const definitionsFilePath = path . join ( rootPath , definitionsFileName )
81+
82+ const templateFilePath = getFilePath ( rootPath , templateFileName )
83+ const definitionsFilePath = getFilePath ( rootPath , definitionsFileName )
84+
7185 const template = fs . readFileSync ( templateFilePath , 'utf8' )
7286 const definitions = loadDefinitions ( definitionsFilePath )
7387 const terms = _ . keys ( definitions )
You can’t perform that action at this time.
0 commit comments