Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions extensions/ql-vscode/gulpfile.ts/appInsights.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import { src, dest } from "gulp";
import replace from "gulp-replace";
import { readFile, writeFile } from "fs/promises";

/** Inject the application insights key into the telemetry file */
export function injectAppInsightsKey() {
export async function injectAppInsightsKey() {
if (!process.env.APP_INSIGHTS_KEY) {
// noop
console.log(
"APP_INSIGHTS_KEY environment variable is not set. So, cannot inject it into the application.",
);
return Promise.resolve();
return;
}

// replace the key
return src(["out/extension.js"])
.pipe(replace(/REPLACE-APP-INSIGHTS-KEY/, process.env.APP_INSIGHTS_KEY))
.pipe(dest("out/"));
const filePath = "out/extension.js";
const content = await readFile(filePath, "utf8");
await writeFile(
filePath,
content.replace(/REPLACE-APP-INSIGHTS-KEY/, process.env.APP_INSIGHTS_KEY),
"utf8",
);
}
16 changes: 9 additions & 7 deletions extensions/ql-vscode/gulpfile.ts/textmate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { dest, src } from "gulp";
import { load } from "js-yaml";
import { objectTransform } from "through2";
import type { TransformCallback } from "stream";
import { Transform } from "stream";
import PluginError from "plugin-error";
import type Vinyl from "vinyl";
import type {
Expand Down Expand Up @@ -247,12 +248,13 @@ function transformFile(yaml: ExtendedTextmateGrammar<ExtendedMatchType>) {
}

export function transpileTextMateGrammar() {
return objectTransform(
(
return new Transform({
objectMode: true,
transform(
file: Vinyl,
_encoding: string,
callback: (err?: Error | null, file?: Vinyl) => void,
): void => {
_encoding: BufferEncoding,
callback: TransformCallback,
): void {
if (file.isNull()) {
callback(null, file);
} else if (file.isBuffer()) {
Expand All @@ -270,7 +272,7 @@ export function transpileTextMateGrammar() {
);
}
},
);
});
}

export function compileTextMateGrammar() {
Expand Down
20 changes: 12 additions & 8 deletions extensions/ql-vscode/gulpfile.ts/typescript.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { gray, red } from "ansi-colors";
import { styleText } from "util";
import { dest, parallel, src, watch } from "gulp";
import esbuild from "gulp-esbuild";
import type { reporter } from "gulp-typescript";
import { createProject } from "gulp-typescript";
import del from "del";
import { pipeline } from "stream/promises";
import { mkdir } from "fs/promises";
import { mkdir, rm } from "fs/promises";
import { join } from "path";

export function goodReporter(): reporter.Reporter {
return {
error: (error, typescript) => {
if (error.tsFile) {
console.log(
`[${gray("gulp-typescript")}] ${red(
`[${styleText("gray", "gulp-typescript")}] ${styleText(
"red",
`${error.fullFilename}(${error.startPosition!.line + 1},${
error.startPosition!.character
}): `,
Expand All @@ -32,10 +33,13 @@ export function goodReporter(): reporter.Reporter {

const tsProject = createProject("tsconfig.json");

export function cleanOutput() {
return tsProject.projectDirectory
? del(`${tsProject.projectDirectory}/out/*`)
: Promise.resolve();
export async function cleanOutput() {
if (tsProject.projectDirectory) {
await rm(join(tsProject.projectDirectory, "out"), {
recursive: true,
force: true,
});
}
}

export function compileEsbuild() {
Expand Down
Loading
Loading