@@ -4,7 +4,6 @@ import { logger } from "../../global/log";
44import { fs } from "./assets" ;
55import process from "process" ;
66
7-
87const zshrcContent = `# This function is used to set up the environment for Weaponized folders and auto source .vscode/.zshrc files
98weapon_vscode_launch_helper () {
109 if [ -n "$PROJECT_FOLDER" ]; then
@@ -17,37 +16,45 @@ weapon_vscode_launch_helper
1716` ;
1817
1918const checkShellProfile = async ( ) : Promise < boolean > => {
20- let stats = await vscode . workspace . fs . stat (
21- vscode . Uri . file ( process . env . HOME + "/.bashrc" )
22- ) ;
23- if ( stats . type === vscode . FileType . File ) {
24- const bashrc = (
25- await vscode . workspace . fs . readFile (
26- vscode . Uri . file ( process . env . HOME + "/.bashrc" )
27- )
28- ) . toString ( ) ;
29- if ( bashrc . includes ( "createhackenv.sh" ) ) {
30- return true ;
31- }
32- if ( bashrc . includes ( "weapon_vscode_launch_helper" ) ) {
33- return true ;
19+ try {
20+ let stats = await vscode . workspace . fs . stat (
21+ vscode . Uri . file ( process . env . HOME + "/.bashrc" )
22+ ) ;
23+ if ( stats . type === vscode . FileType . File ) {
24+ const bashrc = (
25+ await vscode . workspace . fs . readFile (
26+ vscode . Uri . file ( process . env . HOME + "/.bashrc" )
27+ )
28+ ) . toString ( ) ;
29+ if ( bashrc . includes ( "createhackenv.sh" ) ) {
30+ return true ;
31+ }
32+ if ( bashrc . includes ( "weapon_vscode_launch_helper" ) ) {
33+ return true ;
34+ }
3435 }
36+ } catch ( error ) {
37+ logger . error ( `Error checking .bashrc: ${ error } ` ) ;
3538 }
36- stats = await vscode . workspace . fs . stat (
37- vscode . Uri . file ( process . env . HOME + "/.zshrc" )
38- ) ;
39- if ( stats . type === vscode . FileType . File ) {
40- const zshrc = (
41- await vscode . workspace . fs . readFile (
42- vscode . Uri . file ( process . env . HOME + "/.zshrc" )
43- )
44- ) . toString ( ) ;
45- if ( zshrc . includes ( "createhackenv.sh" ) ) {
46- return true ;
47- }
48- if ( zshrc . includes ( "weapon_vscode_launch_helper" ) ) {
49- return true ;
39+ try {
40+ let stats = await vscode . workspace . fs . stat (
41+ vscode . Uri . file ( process . env . HOME + "/.zshrc" )
42+ ) ;
43+ if ( stats . type === vscode . FileType . File ) {
44+ const zshrc = (
45+ await vscode . workspace . fs . readFile (
46+ vscode . Uri . file ( process . env . HOME + "/.zshrc" )
47+ )
48+ ) . toString ( ) ;
49+ if ( zshrc . includes ( "createhackenv.sh" ) ) {
50+ return true ;
51+ }
52+ if ( zshrc . includes ( "weapon_vscode_launch_helper" ) ) {
53+ return true ;
54+ }
5055 }
56+ } catch ( error ) {
57+ logger . error ( `Error checking .zshrc: ${ error } ` ) ;
5158 }
5259 return false ;
5360} ;
@@ -65,12 +72,10 @@ export const checkEnvironmentSetup = async (): Promise<void> => {
6572 vscode . workspace . openTextDocument ( openPath ) . then ( ( doc ) => {
6673 vscode . window . showTextDocument ( doc ) ;
6774 } ) ;
68- vscode . env . clipboard . writeText (
69- zshrcContent
70- ) ;
75+ vscode . env . clipboard . writeText ( zshrcContent ) ;
7176 vscode . window . showWarningMessage (
7277 "[Weaponized] shell profile looks not setup correctly. Please check your shell profile (e.g., .bashrc, .zshrc)." ,
73- "and Copy the content in clipboard to your .zshrc" ,
78+ "and Copy the content in clipboard to your .zshrc"
7479 ) ;
7580 }
7681} ;
0 commit comments