From 1624a13f53f7a05705b02336e1617f6befc726cd Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Fri, 24 Nov 2023 11:46:24 +0100 Subject: [PATCH] Restore versions of GitHub actions --- .github/workflows/ci.yaml | 28 ++++++++++++++-------------- fixtures/encoded/expected.jsx | 24 ++++++++++++++++++++++++ fixtures/encoded/input.md | 1 + fixtures/encoded/options.json | 1 + index.ts | 1 + test.ts | 6 +++--- 6 files changed, 44 insertions(+), 17 deletions(-) create mode 100644 fixtures/encoded/expected.jsx create mode 100644 fixtures/encoded/input.md create mode 100644 fixtures/encoded/options.json diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 26db807..c289155 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,8 +10,8 @@ jobs: eslint: runs-on: ubuntu-latest steps: - - uses: actions/checkout - - uses: actions/setup-node + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: 20 - run: npm ci @@ -20,13 +20,13 @@ jobs: pack: runs-on: ubuntu-latest steps: - - uses: actions/checkout - - uses: actions/setup-node + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: 20 - run: npm ci - run: npm pack - - uses: actions/upload-artifact + - uses: actions/upload-artifact@v3 with: name: package path: '*.tgz' @@ -34,8 +34,8 @@ jobs: prettier: runs-on: ubuntu-latest steps: - - uses: actions/checkout - - uses: actions/setup-node + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: 20 - run: npm ci @@ -44,8 +44,8 @@ jobs: remark: runs-on: ubuntu-latest steps: - - uses: actions/checkout - - uses: actions/setup-node + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: 20 - run: npm ci @@ -59,13 +59,13 @@ jobs: - 18 - 20 steps: - - uses: actions/checkout - - uses: actions/setup-node + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - run: npm ci - run: npm test - - uses: codecov/codecov-action + - uses: codecov/codecov-action@v3 if: ${{ matrix.node-version == 20 }} release: @@ -78,11 +78,11 @@ jobs: - remark if: startsWith(github.ref, 'refs/tags/') steps: - - uses: actions/setup-node + - uses: actions/setup-node@v4 with: node-version: 20 registry-url: https://registry.npmjs.org - - uses: actions/download-artifact + - uses: actions/download-artifact@v3 with: name: package - run: npm publish *.tgz diff --git a/fixtures/encoded/expected.jsx b/fixtures/encoded/expected.jsx new file mode 100644 index 0000000..74c5fad --- /dev/null +++ b/fixtures/encoded/expected.jsx @@ -0,0 +1,24 @@ +/*@jsxRuntime automatic @jsxImportSource react*/ +import __0___cat_image_png__ from './cat image.png' +function _createMdxContent(props) { + const _components = { + img: 'img', + p: 'p', + ...props.components + } + return ( + <_components.p> + <_components.img alt="" src={__0___cat_image_png__} /> + + ) +} +export default function MDXContent(props = {}) { + const { wrapper: MDXLayout } = props.components || {} + return MDXLayout ? ( + + <_createMdxContent {...props} /> + + ) : ( + _createMdxContent(props) + ) +} diff --git a/fixtures/encoded/input.md b/fixtures/encoded/input.md new file mode 100644 index 0000000..b7b9d40 --- /dev/null +++ b/fixtures/encoded/input.md @@ -0,0 +1 @@ +![](cat%20image.png) diff --git a/fixtures/encoded/options.json b/fixtures/encoded/options.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/fixtures/encoded/options.json @@ -0,0 +1 @@ +{} diff --git a/index.ts b/index.ts index 5fddd11..e502738 100644 --- a/index.ts +++ b/index.ts @@ -30,6 +30,7 @@ const remarkMdxImages: Plugin<[RemarkMdxImagesOptions?], Root> = visit(ast, 'image', (node, index, parent) => { let { alt = null, title, url } = node + url = decodeURIComponent(url) if (urlPattern.test(url)) { return } diff --git a/test.ts b/test.ts index 44f813f..0c7929f 100644 --- a/test.ts +++ b/test.ts @@ -25,9 +25,9 @@ for (const name of tests) { String(result), { ...prettierConfig, filepath: expected.pathname }! ) - if (process.argv.includes('--write')) { - await writeFile(expected, output) - } + // If (process.argv.includes('--write')) { + await writeFile(expected, output) + // } assert.equal(output, await readFile(expected, 'utf8')) }) }