Skip to content

Commit de02cdf

Browse files
committed
Fix lint/prettier mishap
1 parent a4cff9b commit de02cdf

1 file changed

Lines changed: 38 additions & 38 deletions

File tree

lib/plugin.js

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { existsSync } from "fs";
1+
import { existsSync } from 'fs';
22
import {
33
cp,
44
mkdir,
@@ -7,24 +7,24 @@ import {
77
readFile,
88
rm,
99
symlink,
10-
} from "fs/promises";
11-
import os from "os";
12-
import path from "path";
10+
} from 'fs/promises';
11+
import os from 'os';
12+
import path from 'path';
1313

14-
import { downloadFile, unzipTo } from "./download.js";
15-
import { execAsync, isOnPath } from "./process.js";
14+
import { downloadFile, unzipTo } from './download.js';
15+
import { execAsync, isOnPath } from './process.js';
1616

1717
/**
1818
* Supported package managers and their no-op commands (used to
1919
* verify their presence by checking if they can be executed)
2020
*/
2121
const pkgCommands = [
22-
{ command: "yarn", noOpFlag: "--help" },
23-
{ command: "npm", noOpFlag: "--help" },
22+
{ command: 'yarn', noOpFlag: '--help' },
23+
{ command: 'npm', noOpFlag: '--help' },
2424
];
2525

2626
const resolvePluginDir = (presentationRoot) =>
27-
path.join(path.resolve(presentationRoot), "plugins");
27+
path.join(path.resolve(presentationRoot), 'plugins');
2828

2929
/**
3030
* Ensure the plugins directory exists in the given presentation root.
@@ -65,8 +65,8 @@ const resolvePkgCommandExec = async () => {
6565
}
6666
}
6767
throw new Error(
68-
"No nodejs package manager available on path. Tried: " +
69-
pkgCommands.map((cmd) => cmd.command).join(", "),
68+
'No nodejs package manager available on path. Tried: ' +
69+
pkgCommands.map((cmd) => cmd.command).join(', '),
7070
);
7171
};
7272

@@ -105,11 +105,11 @@ export const installPlugins = async (
105105
* @throws {Error} - Throws an error if the installation command fails.
106106
*/
107107
const installInPlace = async (targetPath) => {
108-
if (!existsSync(path.join(targetPath, "package.json"))) return;
108+
if (!existsSync(path.join(targetPath, 'package.json'))) return;
109109

110110
const pkgCommand = await resolvePkgCommandExec();
111111

112-
const cmd = [pkgCommand.command, "install"].join(" ");
112+
const cmd = [pkgCommand.command, 'install'].join(' ');
113113

114114
try {
115115
await execAsync(cmd, { cwd: targetPath });
@@ -130,8 +130,8 @@ const installInPlace = async (targetPath) => {
130130
export const resolvePluginSource = async (pluginName, source, heedRoot) => {
131131
if (!source) {
132132
const pluginsDotJSON = await readFile(
133-
path.join(heedRoot, "plugins.json"),
134-
"utf-8",
133+
path.join(heedRoot, 'plugins.json'),
134+
'utf-8',
135135
);
136136
const plugins = JSON.parse(pluginsDotJSON);
137137

@@ -155,7 +155,7 @@ export const resolvePluginSource = async (pluginName, source, heedRoot) => {
155155
* or null if not found.
156156
*/
157157
export const findPluginJson = async (dir) => {
158-
const pluginJsonPath = path.join(dir, "plugin.json");
158+
const pluginJsonPath = path.join(dir, 'plugin.json');
159159
if (existsSync(pluginJsonPath)) {
160160
return dir;
161161
}
@@ -185,7 +185,7 @@ export const findPluginJson = async (dir) => {
185185
*/
186186
export const isPluginPresentInFolder = (presentationRoot, pluginId) => {
187187
return existsSync(
188-
path.join(path.resolve(presentationRoot), "plugins", pluginId),
188+
path.join(path.resolve(presentationRoot), 'plugins', pluginId),
189189
);
190190
};
191191

@@ -217,14 +217,14 @@ export const verifyNotInstalled = (presentationRoot, presJson, pluginName) => {
217217
* @return {string} - The type of the source: 'url', 'local', or 'zip'.
218218
*/
219219
export const determineSourceType = (source) => {
220-
if (source.startsWith("http://") || source.startsWith("https://")) {
221-
return "url";
220+
if (source.startsWith('http://') || source.startsWith('https://')) {
221+
return 'url';
222222
} else if (/^([a-z]+:)?\/\//.test(source)) {
223-
throw new Error(`Unsupported protocol: ${source.split("://")[0]}`);
224-
} else if (source.toLowerCase().endsWith(".zip")) {
225-
return "zip";
223+
throw new Error(`Unsupported protocol: ${source.split('://')[0]}`);
224+
} else if (source.toLowerCase().endsWith('.zip')) {
225+
return 'zip';
226226
}
227-
return "local";
227+
return 'local';
228228
};
229229

230230
/**
@@ -245,14 +245,14 @@ export const installFromSource = async (
245245
sourceType,
246246
) => {
247247
switch (sourceType) {
248-
case "url":
249-
return await installFromUrl(presentationRoot, pluginName, source);
250-
case "local":
251-
return await installFromPath(presentationRoot, pluginName, source);
252-
case "zip":
253-
return await installFromZip(presentationRoot, pluginName, source);
254-
default:
255-
throw new Error("Unknown source");
248+
case 'url':
249+
return await installFromUrl(presentationRoot, pluginName, source);
250+
case 'local':
251+
return await installFromPath(presentationRoot, pluginName, source);
252+
case 'zip':
253+
return await installFromZip(presentationRoot, pluginName, source);
254+
default:
255+
throw new Error('Unknown source');
256256
}
257257
};
258258

@@ -268,7 +268,7 @@ export const installFromSource = async (
268268
* config.
269269
*/
270270
const installFromUrl = async (presentationRoot, pluginName, source) => {
271-
const tmpDir = await mkdtemp(path.join(os.tmpdir(), "heed-plugin-"));
271+
const tmpDir = await mkdtemp(path.join(os.tmpdir(), 'heed-plugin-'));
272272
try {
273273
const zipPath = path.join(tmpDir, `heed-${pluginName}.zip`);
274274

@@ -294,7 +294,7 @@ const installFromZip = async (presentationRoot, pluginName, source) => {
294294
const unzippedFolder = await unzipTo(source);
295295
const sourceDir = await findPluginJson(unzippedFolder);
296296
if (!sourceDir) {
297-
throw new Error("Downloaded ZIP Archive does not contain a plugin.");
297+
throw new Error('Downloaded ZIP Archive does not contain a plugin.');
298298
}
299299
return await installFromPath(presentationRoot, pluginName, sourceDir);
300300
};
@@ -320,7 +320,7 @@ export const installFromPath = async (
320320
let pluginDotJson = null;
321321
try {
322322
pluginDotJson = JSON.parse(
323-
await readFile(path.join(source, "plugin.json")),
323+
await readFile(path.join(source, 'plugin.json')),
324324
);
325325
} catch (e) {
326326
throw new Error(`Unable to read plugin.json: ${e}`);
@@ -362,9 +362,9 @@ export const loadPluginDefinitions = async (presentationRoot, presentation) => {
362362
const plugins = {};
363363

364364
for (const pluginId of pluginIds) {
365-
const pluginJsonPath = path.join(pluginDir, pluginId, "plugin.json");
365+
const pluginJsonPath = path.join(pluginDir, pluginId, 'plugin.json');
366366
if (existsSync(pluginJsonPath)) {
367-
const pluginDef = JSON.parse(await readFile(pluginJsonPath, "utf8"));
367+
const pluginDef = JSON.parse(await readFile(pluginJsonPath, 'utf8'));
368368
plugins[pluginId] = Object.assign(presentation.plugins[pluginId], {
369369
definition: pluginDef,
370370
});
@@ -408,8 +408,8 @@ export const applyHooks = (ir, presentation) => {
408408
if (Array.isArray(hook.components)) {
409409
shouldApply = false;
410410
for (const pattern of hook.components) {
411-
const matcher = pattern.includes(":*")
412-
? (type) => type.split(":")[0] === pattern.split(":")[0]
411+
const matcher = pattern.includes(':*')
412+
? (type) => type.split(':')[0] === pattern.split(':')[0]
413413
: (type) => type === pattern;
414414

415415
if (sectionHasMatchingComponent(ir.contents, matcher)) {

0 commit comments

Comments
 (0)