@@ -574,6 +574,9 @@ async function showNoWgetError(): Promise<void> {
574574 "wget not found in Path. Please install wget and ensure " +
575575 "it is available in Path. " +
576576 "See the Zephyr notes in the pico-vscode README for guidance." ,
577+ {
578+ modal : true ,
579+ } ,
577580 "Open README"
578581 ) ;
579582 if ( response === "Open README" ) {
@@ -593,7 +596,7 @@ async function checkMacosLinuxDeps(): Promise<boolean> {
593596
594597 const wget = await which ( "wget" , { nothrow : true } ) ;
595598 if ( ! wget ) {
596- await showNoWgetError ( ) ;
599+ void showNoWgetError ( ) ;
597600
598601 return false ;
599602 }
@@ -628,7 +631,7 @@ async function checkWindowsDeps(): Promise<boolean> {
628631
629632 const wget = await which ( "wget" , { nothrow : true } ) ;
630633 if ( ! wget ) {
631- await showNoWgetError ( ) ;
634+ void showNoWgetError ( ) ;
632635
633636 return false ;
634637 }
@@ -1718,3 +1721,48 @@ export async function zephyrVerifyCMakeCache(
17181721 return ;
17191722 }
17201723}
1724+
1725+ export async function zephyrGetSelectedSnippets (
1726+ workspaceUri : Uri
1727+ ) : Promise < string [ ] > {
1728+ const snippetsUri = Uri . joinPath ( workspaceUri , ".vscode" , "tasks.json" ) ;
1729+
1730+ // search for "Compile Project" get every i+1 where i is an index and args[i]=="-S" || "--snippet"
1731+ try {
1732+ await workspace . fs . stat ( snippetsUri ) ;
1733+
1734+ const td = new TextDecoder ( "utf-8" ) ;
1735+ const tasksJson = JSON . parse (
1736+ td . decode ( await workspace . fs . readFile ( snippetsUri ) )
1737+ ) as { tasks : ITask [ ] } ;
1738+
1739+ const compileTask = tasksJson . tasks . find (
1740+ t => t . label === "Compile Project"
1741+ ) ;
1742+ if ( compileTask === undefined ) {
1743+ return [ ] ;
1744+ }
1745+
1746+ const selectedSnippets : string [ ] = [ ] ;
1747+ for ( let i = 0 ; i < compileTask . args . length ; i ++ ) {
1748+ if ( compileTask . args [ i ] === "-S" || compileTask . args [ i ] === "--snippet" ) {
1749+ if ( i + 1 < compileTask . args . length ) {
1750+ selectedSnippets . push ( compileTask . args [ i + 1 ] ) ;
1751+ }
1752+ }
1753+ }
1754+
1755+ return selectedSnippets ;
1756+ } catch ( error ) {
1757+ Logger . warn (
1758+ LoggerSource . zephyrSetup ,
1759+ `Failed to read tasks.json file: ${ unknownErrorToString ( error ) } `
1760+ ) ;
1761+ void window . showWarningMessage (
1762+ "Failed to read tasks.json file. " +
1763+ "Make sure the file exists and has a Compile Project task."
1764+ ) ;
1765+
1766+ return [ ] ;
1767+ }
1768+ }
0 commit comments