Skip to content

Commit

Permalink
fix: WIP attempt to fix path resolution for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
vnphanquang committed Nov 21, 2024
1 parent 077bd47 commit 8e210e8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# os: [ubuntu-latest, macos-latest, windows-latest]
os: [windows-latest]
timeout-minutes: 5
steps:
- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"prepublishOnly": "publint",
"lint": "eslint src/**/*",
"test": "vitest --coverage",
"ci:test": "vitest run --coverage",
"ci:test": "vitest run --coverage --allowOnly",
"ci:version": "changeset version && pnpm install --no-frozen-lockfile",
"ci:publish": "changeset publish && pnpm install"
},
Expand Down
13 changes: 9 additions & 4 deletions src/plugin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from 'fs';
import path from 'path';

import { icons } from '@phosphor-icons/core';
import { resolve } from 'import-meta-resolve';
Expand Down Expand Up @@ -51,10 +52,14 @@ export default createPlugin.withOptions(

let url = 'icon-not-found';
if (ICON_SET.has(name) && VARIANTS.includes(weight)) {
let filepath = resolve(
`@phosphor-icons/core/assets/${weight}/${name}${weight === 'regular' ? '' : `-${weight}`}.svg`,
import.meta.url,
).replace('file://', '');
let filepath = path.resolve(
resolve(
`@phosphor-icons/core/assets/${weight}/${name}${weight === 'regular' ? '' : `-${weight}`}.svg`,
import.meta.url,
).replace('file://', ''),
);
console.log('dirname: ', import.meta.dirname);
console.log('icon:', filepath);

if (fs.existsSync(filepath)) {
const svgStr = fs.readFileSync(filepath, { encoding: 'base64' });
Expand Down
2 changes: 1 addition & 1 deletion tests/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface Run {
}

function tests(run: Run, version: number) {
test('default', async function ({ expect }) {
test.only('default', async function ({ expect }) {
const result = await run([...COMMON_CANDIDATES, 'ph', 'ph-[info]']);
await expect(result).toMatchFileSnapshot(

Check failure on line 21 in tests/plugin.test.ts

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

tests/plugin.test.ts > v4 > default

Error: Snapshot `v4 > default 1` mismatched - Expected + Received @@ -26,9 +26,9 @@ .w-4 { width: calc(var(--spacing) * 4); } .ph-\[info\] { @layer icons { - --ph-url: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTYgMjU2IiBmaWxsPSJjdXJyZW50Q29sb3IiPjxwYXRoIGQ9Ik0xMjgsMjRBMTA0LDEwNCwwLDEsMCwyMzIsMTI4LDEwNC4xMSwxMDQuMTEsMCwwLDAsMTI4LDI0Wm0wLDE5MmE4OCw4OCwwLDEsMSw4OC04OEE4OC4xLDg4LjEsMCwwLDEsMTI4LDIxNlptMTYtNDBhOCw4LDAsMCwxLTgsOCwxNiwxNiwwLDAsMS0xNi0xNlYxMjhhOCw4LDAsMCwxLDAtMTYsMTYsMTYsMCwwLDEsMTYsMTZ2NDBBOCw4LDAsMCwxLDE0NCwxNzZaTTExMiw4NGExMiwxMiwwLDEsMSwxMiwxMkExMiwxMiwwLDAsMSwxMTIsODRaIi8+PC9zdmc+); + --ph-url: icon-not-found; } } } ❯ tests/plugin.test.ts:21:3

Check failure on line 21 in tests/plugin.test.ts

View workflow job for this annotation

GitHub Actions / Test (windows-latest)

tests/plugin.test.ts > v3 > default

Error: Snapshot `v3 > default 1` mismatched - Expected + Received @@ -19,8 +19,8 @@ display: inline-block } } @layer icons { .ph-\[info\] { - --ph-url: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTYgMjU2IiBmaWxsPSJjdXJyZW50Q29sb3IiPjxwYXRoIGQ9Ik0xMjgsMjRBMTA0LDEwNCwwLDEsMCwyMzIsMTI4LDEwNC4xMSwxMDQuMTEsMCwwLDAsMTI4LDI0Wm0wLDE5MmE4OCw4OCwwLDEsMSw4OC04OEE4OC4xLDg4LjEsMCwwLDEsMTI4LDIxNlptMTYtNDBhOCw4LDAsMCwxLTgsOCwxNiwxNiwwLDAsMS0xNi0xNlYxMjhhOCw4LDAsMCwxLDAtMTYsMTYsMTYsMCwwLDEsMTYsMTZ2NDBBOCw4LDAsMCwxLDE0NCwxNzZaTTExMiw4NGExMiwxMiwwLDEsMSwxMiwxMkExMiwxMiwwLDAsMSwxMTIsODRaIi8+PC9zdmc+) + --ph-url: icon-not-found } } ❯ tests/plugin.test.ts:21:3
path.resolve(import.meta.dirname, '__snapshots__', `v${version}/default.css`),
Expand Down

0 comments on commit 8e210e8

Please sign in to comment.