Skip to content

Commit

Permalink
Ensure examples clone is up to date
Browse files Browse the repository at this point in the history
  • Loading branch information
will-v-pi committed Aug 8, 2024
1 parent a1f5f3d commit 7a8f9a2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
16 changes: 9 additions & 7 deletions src/utils/download.mts
Original file line number Diff line number Diff line change
Expand Up @@ -768,13 +768,15 @@ export async function downloadAndInstallOpenOCD(
}.${assetExt}`;

const extraCallback = (): void => {
// on darwin and linux platforms create windows compatible alias
// so confiuration works on all platforms
symlinkSync(
join(targetDirectory, "openocd"),
join(targetDirectory, "openocd.exe"),
"file"
);
if (process.platform !== "win32") {
// on darwin and linux platforms create windows compatible alias
// so confiuration works on all platforms
symlinkSync(
join(targetDirectory, "openocd"),
join(targetDirectory, "openocd.exe"),
"file"
);
}
};

return downloadAndInstallGithubAsset(
Expand Down
23 changes: 20 additions & 3 deletions src/utils/examplesUtil.mts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { join as joinPosix } from "path/posix";
import Logger from "../logger.mjs";
import { existsSync, readFileSync } from "fs";
import { existsSync, readFileSync, rmSync } from "fs";
import { homedir } from "os";
import { getGit, sparseCheckout, sparseCloneRepository } from "./gitUtil.mjs";
import { getGit, sparseCheckout, sparseCloneRepository, execAsync } from "./gitUtil.mjs";

Check warning on line 5 in src/utils/examplesUtil.mts

View workflow job for this annotation

GitHub Actions / build

This line has a length of 89. Maximum allowed is 80
import Settings from "../settings.mjs";
import { checkForInstallationRequirements } from "./requirementsUtil.mjs";
import { cp } from "fs/promises";
Expand All @@ -16,6 +16,10 @@ const EXAMPLES_REPOSITORY_URL =
const EXAMPLES_JSON_URL =
"https://raspberrypi.github.io/pico-vscode/" +
`${CURRENT_DATA_VERSION}/examples.json`;
const EXAMPLES_GITREF =
"7fe60d6b4027771e45d97f207532c41b1d8c5418";
const EXAMPLES_TAG =
"sdk-2.0.0";

export interface Example {
path: string;
Expand Down Expand Up @@ -134,10 +138,23 @@ export async function setupExample(

const gitPath = await getGit(settings);

if (existsSync(examplesRepoPath)) {
let ref = await execAsync(

Check failure on line 142 in src/utils/examplesUtil.mts

View workflow job for this annotation

GitHub Actions / build

'ref' is never reassigned. Use 'const' instead
`cd "${examplesRepoPath}" && ${
process.env.ComSpec === "powershell.exe" ? "&" : ""
}"${gitPath}" rev-parse HEAD`
);
Logger.log(`Examples git ref is ${ref.stdout}\n`);
if (ref.stdout.trim() !== EXAMPLES_GITREF) {
Logger.log(`Removing old examples repo\n`);
rmSync(examplesRepoPath, { recursive: true, force: true });
}
}

if (!existsSync(examplesRepoPath)) {
const result = await sparseCloneRepository(
EXAMPLES_REPOSITORY_URL,
"master",
EXAMPLES_TAG,
examplesRepoPath,
gitPath
);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/gitUtil.mts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { homedir } from "os";
import which from "which";
import { window } from "vscode";

const execAsync = promisify(exec);
export const execAsync = promisify(exec);

/**
* Get installed version of git, and install it if it isn't already
Expand Down

0 comments on commit 7a8f9a2

Please sign in to comment.