Skip to content

Commit

Permalink
chore: add shiki as external package
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay-Karia committed Aug 11, 2024
1 parent a5291e2 commit ff19045
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 31 deletions.
17 changes: 7 additions & 10 deletions dist/npm-to-yarn.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -691,21 +691,18 @@ function convert(str, to) {
* Returns highlighted html string
*/
function highlight(command, theme) {
if (theme === void 0) { theme = "light"; }
if (theme === void 0) { theme = 'light'; }
return __awaiter(this, void 0, void 0, function () {
var html, _a, _b;
return __generator(this, function (_c) {
switch (_c.label) {
var html;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, codeToHtml(command, {
lang: 'javascript',
lang: 'shell',
theme: "github-".concat(theme)
})];
case 1:
html = _c.sent();
_b = (_a = console).log;
return [4 /*yield*/, html];
case 2:
_b.apply(_a, [_c.sent()]);
html = _a.sent();
console.log(html);
return [2 /*return*/];
}
});
Expand Down
2 changes: 1 addition & 1 deletion dist/npm-to-yarn.mjs.map

Large diffs are not rendered by default.

17 changes: 7 additions & 10 deletions dist/npm-to-yarn.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/npm-to-yarn.umd.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ export declare function convert(str: string, to: 'npm' | 'yarn' | 'pnpm' | 'bun'
/**
* Returns highlighted html string
*/
export declare function highlight(command: string, theme?: "light" | "dark"): Promise<void>;
export declare function highlight(command: string, theme?: 'light' | 'dark'): Promise<void>;
14 changes: 11 additions & 3 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,19 @@ export default [
file: 'dist/npm-to-yarn.mjs',
format: 'es',
name: 'n2y',
sourcemap: true
sourcemap: true,
globals: {
shiki: 'shiki'
}
},
{
file: 'dist/npm-to-yarn.umd.js',
format: 'umd',
name: 'n2y',
sourcemap: true
sourcemap: true,
globals: {
shiki: 'shiki'
}
}
],
plugins: [
Expand All @@ -28,7 +34,9 @@ export default [
})
],
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: [],
external: [
'shiki',
],
watch: {
include: 'src/**'
}
Expand Down
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { npmToYarn } from './npmToYarn'
import { npmToPnpm } from './npmToPnpm'
import { npmToBun } from './npmToBun'

import { codeToHtml } from "shiki"
import {codeToHtml} from 'shiki';

/**
* Converts between npm and yarn command
*/
export function convert(str: string, to: 'npm' | 'yarn' | 'pnpm' | 'bun'): string {
export function convert (str: string, to: 'npm' | 'yarn' | 'pnpm' | 'bun'): string {
if (to === 'npm') {
return str.replace(/yarn(?: +([^&\n\r]*))?/gm, yarnToNPM)
} else if (to === 'pnpm') {
Expand All @@ -23,11 +23,11 @@ export function convert(str: string, to: 'npm' | 'yarn' | 'pnpm' | 'bun'): strin
/**
* Returns highlighted html string
*/
export async function highlight(command: string, theme: "light" | "dark" = "light") {
export async function highlight (command: string, theme: 'light' | 'dark' = 'light') {
const html = await codeToHtml(command, {
lang: 'javascript',
lang: 'shell',
theme: `github-${theme}`
})

console.log(await html)
console.log(html)
}

0 comments on commit ff19045

Please sign in to comment.