Skip to content

Commit

Permalink
Adds more logging and null check to WIKI Updater (#1570)
Browse files Browse the repository at this point in the history
* Add a Codespaces defintion with sensible extensions
* Add more logging on content loading a null check on the content string
#1569
  • Loading branch information
rfennell authored Nov 25, 2023
1 parent aa1b2d8 commit a3b5bbf
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
{
"name": "Node.js & TypeScript",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-20-bullseye",
// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"github.vscode-pull-request-github",
"github.copilot"
]
}
},
// Commands to be run after the container is created.
"postCreateCommand": [
"echo 'Add PWSH'",
"wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb",
"sudo dpkg -i packages-microsoft-prod.deb",
"sudo apt-get update",
"sudo apt-get install -y powershell"
]
}
6 changes: 6 additions & 0 deletions Extensions/WikiUpdater/WikiUpdaterTask/src/GitWikiFuntions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ export async function UpdateGitWikiFile(
mode) {
const git = simpleGit();

// show error if content is null
if (!contents) {
logError(`The new content is null, so cannot be used to update the wiki`);
return;
}

let remote = "";
let logremote = ""; // used to make sure we hide the password in logs
var extraHeaders = []; // Add handling for #613
Expand Down
2 changes: 2 additions & 0 deletions Extensions/WikiUpdater/WikiUpdaterTask/src/GitWikiTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ var haveData = true;
var contents; // we late declare as it might be buffer or string
if (dataIsFile === true) {
if (fs.existsSync(sourceFile)) {
logInfo(`Reading file ${sourceFile}`);
if (fixLineFeeds) {
contents = fs.readFileSync(sourceFile, "utf8");
} else {
Expand All @@ -106,6 +107,7 @@ if (dataIsFile === true) {
}
} else {
// we do this late copy so that we can use the same property for different encodings with a type clash
logInfo(`Using contents string directly input`);
contents = contentsInput;
}

Expand Down

0 comments on commit a3b5bbf

Please sign in to comment.