Skip to content

Commit ff19045

Browse files
committed
chore: add shiki as external package
1 parent a5291e2 commit ff19045

File tree

7 files changed

+33
-31
lines changed

7 files changed

+33
-31
lines changed

dist/npm-to-yarn.mjs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -691,21 +691,18 @@ function convert(str, to) {
691691
* Returns highlighted html string
692692
*/
693693
function highlight(command, theme) {
694-
if (theme === void 0) { theme = "light"; }
694+
if (theme === void 0) { theme = 'light'; }
695695
return __awaiter(this, void 0, void 0, function () {
696-
var html, _a, _b;
697-
return __generator(this, function (_c) {
698-
switch (_c.label) {
696+
var html;
697+
return __generator(this, function (_a) {
698+
switch (_a.label) {
699699
case 0: return [4 /*yield*/, codeToHtml(command, {
700-
lang: 'javascript',
700+
lang: 'shell',
701701
theme: "github-".concat(theme)
702702
})];
703703
case 1:
704-
html = _c.sent();
705-
_b = (_a = console).log;
706-
return [4 /*yield*/, html];
707-
case 2:
708-
_b.apply(_a, [_c.sent()]);
704+
html = _a.sent();
705+
console.log(html);
709706
return [2 /*return*/];
710707
}
711708
});

dist/npm-to-yarn.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/npm-to-yarn.umd.js

Lines changed: 7 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/npm-to-yarn.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ export declare function convert(str: string, to: 'npm' | 'yarn' | 'pnpm' | 'bun'
55
/**
66
* Returns highlighted html string
77
*/
8-
export declare function highlight(command: string, theme?: "light" | "dark"): Promise<void>;
8+
export declare function highlight(command: string, theme?: 'light' | 'dark'): Promise<void>;

rollup.config.mjs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ export default [
88
file: 'dist/npm-to-yarn.mjs',
99
format: 'es',
1010
name: 'n2y',
11-
sourcemap: true
11+
sourcemap: true,
12+
globals: {
13+
shiki: 'shiki'
14+
}
1215
},
1316
{
1417
file: 'dist/npm-to-yarn.umd.js',
1518
format: 'umd',
1619
name: 'n2y',
17-
sourcemap: true
20+
sourcemap: true,
21+
globals: {
22+
shiki: 'shiki'
23+
}
1824
}
1925
],
2026
plugins: [
@@ -28,7 +34,9 @@ export default [
2834
})
2935
],
3036
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
31-
external: [],
37+
external: [
38+
'shiki',
39+
],
3240
watch: {
3341
include: 'src/**'
3442
}

src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import { npmToYarn } from './npmToYarn'
33
import { npmToPnpm } from './npmToPnpm'
44
import { npmToBun } from './npmToBun'
55

6-
import { codeToHtml } from "shiki"
6+
import {codeToHtml} from 'shiki';
77

88
/**
99
* Converts between npm and yarn command
1010
*/
11-
export function convert(str: string, to: 'npm' | 'yarn' | 'pnpm' | 'bun'): string {
11+
export function convert (str: string, to: 'npm' | 'yarn' | 'pnpm' | 'bun'): string {
1212
if (to === 'npm') {
1313
return str.replace(/yarn(?: +([^&\n\r]*))?/gm, yarnToNPM)
1414
} else if (to === 'pnpm') {
@@ -23,11 +23,11 @@ export function convert(str: string, to: 'npm' | 'yarn' | 'pnpm' | 'bun'): strin
2323
/**
2424
* Returns highlighted html string
2525
*/
26-
export async function highlight(command: string, theme: "light" | "dark" = "light") {
26+
export async function highlight (command: string, theme: 'light' | 'dark' = 'light') {
2727
const html = await codeToHtml(command, {
28-
lang: 'javascript',
28+
lang: 'shell',
2929
theme: `github-${theme}`
3030
})
3131

32-
console.log(await html)
32+
console.log(html)
3333
}

0 commit comments

Comments
 (0)