1111 *
1212 * To avoid making an extra config value for the extension that one has to manage say in a Settings file or internal data, the approach is rather to use the existing commit template pattern in Git.
1313 */
14- import * as fs from 'fs' ;
15- import * as path from ' path' ;
14+ import * as fs from "fs" ;
15+ import * as path from " path" ;
1616import { getWorkspaceFolder } from "../workspace" ;
1717import { execute } from "./cli" ;
1818
19- const CONFIG_SUBCOMMAND = "config"
20- const COMMIT_TEMPLATE_IDENTIFIER = ' commit.template'
19+ const CONFIG_SUBCOMMAND = "config" ;
20+ const COMMIT_TEMPLATE_IDENTIFIER = " commit.template" ;
2121
2222/**
2323 * Get a value from the Git config.
2424 *
2525 * The CLI will assume local (project) project by default.
2626 */
2727export async function _getConfigValue ( options : string [ ] ) {
28- const workspace = getWorkspaceFolder ( )
28+ const workspace = getWorkspaceFolder ( ) ;
2929 const { stdout, stderr } = await execute (
3030 workspace ,
3131 CONFIG_SUBCOMMAND ,
@@ -36,7 +36,7 @@ export async function _getConfigValue(options: string[]) {
3636 console . debug ( `stderr for 'git ${ CONFIG_SUBCOMMAND } ' command:` , stderr ) ;
3737 }
3838
39- return stdout
39+ return stdout ;
4040}
4141
4242/**
@@ -46,10 +46,10 @@ export async function _getConfigValue(options: string[]) {
4646 */
4747async function _getCommitTemplatePath ( ) {
4848 try {
49- const options = [ COMMIT_TEMPLATE_IDENTIFIER ]
50- return await _getConfigValue ( options )
49+ const options = [ COMMIT_TEMPLATE_IDENTIFIER ] ;
50+ return await _getConfigValue ( options ) ;
5151 } catch ( _e ) {
52- return null
52+ return null ;
5353 }
5454}
5555
@@ -59,26 +59,26 @@ async function _getCommitTemplatePath() {
5959 * NB. Use current workspace as the base path.
6060 */
6161function _readFile ( filePath : string ) {
62- const workspace = getWorkspaceFolder ( )
63- const p = path . join ( workspace , filePath )
62+ const workspace = getWorkspaceFolder ( ) ;
63+ const p = path . join ( workspace , filePath ) ;
6464
65- let value
65+ let value ;
6666
6767 try {
68- value = fs . readFileSync ( p , "utf-8" )
68+ value = fs . readFileSync ( p , "utf-8" ) ;
6969 } catch ( err ) {
70- console . error ( `Could not find template file: ${ p } . ${ err . toString ( ) } ` )
70+ console . error ( `Could not find template file: ${ p } . ${ err . toString ( ) } ` ) ;
7171
72- return null
72+ return null ;
7373 }
7474
7575 if ( ! value ) {
76- return null
76+ return null ;
7777 }
7878
79- console . debug ( `Read ${ p } and found: ${ value } ` )
79+ console . debug ( `Read ${ p } and found: ${ value } ` ) ;
8080
81- return value
81+ return value ;
8282}
8383
8484/**
@@ -87,12 +87,12 @@ function _readFile(filePath: string) {
8787 * Return null if file is not configured or file is missing, without aborting.
8888 */
8989export async function getCommitTemplateValue ( ) {
90- const filePath = await _getCommitTemplatePath ( )
90+ const filePath = await _getCommitTemplatePath ( ) ;
9191
9292 if ( ! filePath ) {
93- console . error ( `Could not read missing file: ${ filePath } ` )
94- return null
93+ console . error ( `Could not read missing file: ${ filePath } ` ) ;
94+ return null ;
9595 }
9696
97- return _readFile ( filePath )
97+ return _readFile ( filePath ) ;
9898}
0 commit comments