fix
This commit is contained in:
		| @@ -19,20 +19,20 @@ import { FileMapper } from './file_mapper'; | ||||
| import { CopyrightOptions } from './copyright_options'; | ||||
|  | ||||
| export default class Copyright implements Snippet { | ||||
|   private options: CopyrightOptions | null = null; | ||||
|   private cwd = ''; | ||||
|   private loaded_from_config = false; | ||||
|   private _options: CopyrightOptions | null = null; | ||||
|   private _cwd = ''; | ||||
|   private _loaded_from_config = false; | ||||
|  | ||||
|   async start (cwd: string): Promise<void> { | ||||
|     this.cwd = cwd; | ||||
|     this._cwd = cwd; | ||||
|     await this.load_options_file (); | ||||
|     if (!this.options) | ||||
|     if (!this._options) | ||||
|       await this.gather_options (); | ||||
|  | ||||
|     const options = this.options as CopyrightOptions; | ||||
|     const options = this._options as CopyrightOptions; | ||||
|  | ||||
|     await FileMapper.map_all_files ( | ||||
|       this.cwd, | ||||
|       this._cwd, | ||||
|       this.fix_file_license.bind (this) | ||||
|     ); | ||||
|  | ||||
| @@ -55,7 +55,7 @@ export default class Copyright implements Snippet { | ||||
|       ); | ||||
|     } | ||||
|  | ||||
|     if (!this.loaded_from_config && await new Confirm ( | ||||
|     if (!this._loaded_from_config && await new Confirm ( | ||||
|       { message: 'should those settings be saved for the next run?' } | ||||
|     ) | ||||
|       .run () | ||||
| @@ -64,27 +64,27 @@ export default class Copyright implements Snippet { | ||||
|   } | ||||
|  | ||||
|   private async gather_options (): Promise<void> { | ||||
|     this.options = (new CopyrightOptions); | ||||
|     this.options.author = await new Input ({ message: 'author' }) | ||||
|     this._options = (new CopyrightOptions); | ||||
|     this._options.author = await new Input ({ message: 'author' }) | ||||
|       .run () | ||||
|       .catch (DialogHandler.catch); | ||||
|     this.options.email = await new Input ({ message: 'email' }) | ||||
|     this._options.email = await new Input ({ message: 'email' }) | ||||
|       .run () | ||||
|       .catch (DialogHandler.catch); | ||||
|     this.options.company = await new Input ({ message: 'company' }) | ||||
|     this._options.company = await new Input ({ message: 'company' }) | ||||
|       .run () | ||||
|       .catch (DialogHandler.catch); | ||||
|     this.options.software = await new Input ({ message: 'software name' }) | ||||
|     this._options.software = await new Input ({ message: 'software name' }) | ||||
|       .run () | ||||
|       .catch (DialogHandler.catch); | ||||
|     this.options.has_license = await new Confirm ({ | ||||
|     this._options.has_license = await new Confirm ({ | ||||
|       message: | ||||
|        'would you like to specify a license?' | ||||
|     }) | ||||
|       .run () | ||||
|       .catch (DialogHandler.catch); | ||||
|     if (this.options.has_license) { | ||||
|       this.options.license = await new AutoComplete ({ | ||||
|     if (this._options.has_license) { | ||||
|       this._options.license = await new AutoComplete ({ | ||||
|         name:    'license', | ||||
|         message: 'choose a license', | ||||
|         limit:   10, | ||||
| @@ -96,8 +96,8 @@ export default class Copyright implements Snippet { | ||||
|   } | ||||
|  | ||||
|   private async load_options_file (): Promise<void> { | ||||
|     const file_path = path.join (this.cwd, '.liconfig.json'); | ||||
|     this.options = null; | ||||
|     const file_path = path.join (this._cwd, '.liconfig.json'); | ||||
|     this._options = null; | ||||
|  | ||||
|     if (await fs.pathExists (file_path)) { | ||||
|       const options = JSON.parse ( | ||||
| @@ -116,17 +116,17 @@ license: ${options.license}`); | ||||
|         .run () | ||||
|         .catch (DialogHandler.catch); | ||||
|       if (should_load) { | ||||
|         this.options = options; | ||||
|         this.loaded_from_config = true; | ||||
|         this._options = options; | ||||
|         this._loaded_from_config = true; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   private async save_options_file (): Promise<void> { | ||||
|     const file_path = path.join (this.cwd, '.liconfig.json'); | ||||
|     const file_path = path.join (this._cwd, '.liconfig.json'); | ||||
|     await fs.writeFile ( | ||||
|       file_path, | ||||
|       JSON.stringify (this.options, null, 2), | ||||
|       JSON.stringify (this._options, null, 2), | ||||
|       'utf-8' | ||||
|     ); | ||||
|   } | ||||
| @@ -143,7 +143,7 @@ license: ${options.license}`); | ||||
|       return null; | ||||
|     return (shebang_line ? shebang_line[0] : '') | ||||
|      + CopyrightGenerator.get_copyright_notice ( | ||||
|        this.options as CopyrightOptions | ||||
|        this._options as CopyrightOptions | ||||
|      ) | ||||
|      + data.replace (regex, '') | ||||
|        .replace (shebang, ''); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user