Skip to content

Commit

Permalink
Warn when using extension.json (#535)
Browse files Browse the repository at this point in the history
This PR adds a warning when an `extension.json` manifest is detected.

`extension.toml` should be preferred instead.
  • Loading branch information
maxdeviant authored Apr 12, 2024
1 parent 8d53ac1 commit 7457f87
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,25 @@ export async function readTomlFile(path) {
throw new Error(`Failed to parse TOML file '${path}': ${err}`);
}
}

/**
* @param {string} path
* @returns {Promise<boolean>}
*/
export async function fileExists(path) {
try {
const stat = await fs.stat(path);
return stat.isFile();
} catch (err) {
if (
err &&
typeof err === "object" &&
"code" in err &&
err.code === "ENOENT"
) {
return false;
}

throw err;
}
}
8 changes: 7 additions & 1 deletion src/package-extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import toml from "@iarna/toml";
import assert from "node:assert";
import fs from "node:fs/promises";
import path from "node:path";
import { readTomlFile } from "./lib/fs.js";
import { fileExists, readTomlFile } from "./lib/fs.js";
import {
checkoutGitSubmodule,
readGitmodules,
Expand Down Expand Up @@ -143,6 +143,12 @@ async function packageExtension(
const SCRATCH_DIR = "./scratch";
await fs.mkdir(SCRATCH_DIR, { recursive: true });

if (await fileExists(path.join(extensionPath, "extension.json"))) {
console.warn(
"The `extension.json` manifest format has been superseded by `extension.toml`",
);
}

const zedExtensionOutput = await exec(
"./zed-extension",
[
Expand Down

0 comments on commit 7457f87

Please sign in to comment.