Skip to content

Commit

Permalink
Download hcl textmate grammer from syntax repo
Browse files Browse the repository at this point in the history
  • Loading branch information
jpogran committed Jun 11, 2024
1 parent 53079fc commit 9a6175d
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions build/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async function downloadSyntax(info: ExtensionInfo) {
const release = `v${info.syntaxVersion}`;

const productName = info.name.replace('-preview', '');
const fileName = `${productName}.tmGrammar.json`;
let fileName = `${productName}.tmGrammar.json`;

const cwd = path.resolve(__dirname);
const buildDir = path.basename(cwd);
Expand All @@ -129,17 +129,36 @@ async function downloadSyntax(info: ExtensionInfo) {

fs.mkdirSync(installPath);

const url = `https://github.com/hashicorp/syntax/releases/download/${release}/${fileName}`;
let url = `https://github.com/hashicorp/syntax/releases/download/${release}/${fileName}`;
if (process.env.downloader_log === 'true') {
console.log(`Downloading: ${url}`);
}
// const content = await got({ url }).text();
// fs.writeFileSync(fpath, content);
const buffer = await fileFromUrl(url);
let buffer = await fileFromUrl(url);
fs.writeFileSync(fpath, buffer);
if (process.env.downloader_log === 'true') {
console.log(`Download completed: ${fpath}`);
}

fileName = `hcl.tmGrammar.json`;
const hpath = path.join(installPath, fileName);
if (fs.existsSync(hpath)) {
if (process.env.downloader_log === 'true') {
console.log(`Syntax path exists at ${hpath}. Exiting`);
}
return;
}

url = `https://github.com/hashicorp/syntax/releases/download/${release}/${fileName}`;
if (process.env.downloader_log === 'true') {
console.log(`Downloading: ${url}`);
}
buffer = await fileFromUrl(url);
fs.writeFileSync(hpath, buffer);
if (process.env.downloader_log === 'true') {
console.log(`Download completed: ${fpath}`);
}
}

async function run(platform: string, architecture: string) {
Expand Down

0 comments on commit 9a6175d

Please sign in to comment.