Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(update): replaced path with pathe #889

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hookFunctions/nitro/init.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { promises as fsPromises } from 'fs';
import { basename, dirname, join, resolve } from 'path';
import { basename, dirname, join, resolve } from 'pathe';
import { parseDocument } from 'htmlparser2';
import { load } from 'cheerio';
import { render } from 'dom-serializer';
Expand Down Expand Up @@ -37,7 +37,7 @@
nuxt.options.vite.build.assetsDir
);
const filepath = join(publicDir, basename($el.attr('href')));
const fileContent = await fsPromises.readFile(filepath, 'utf-8');

Check warning on line 40 in src/hookFunctions/nitro/init.mjs

View workflow job for this annotation

GitHub Actions / Test & Build (ubuntu-latest, 19)

Found readFile from package "fs" with non literal argument at index 0

let urls = getUrlValues(fileContent);
urls = prepareUrls(urls, dir);
Expand Down
2 changes: 1 addition & 1 deletion test/tests/html.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-secrets/no-secrets */

import { join } from 'path';
import { join } from 'pathe';
import { describe, it, expect } from 'vitest';
import { getDom, getLinkPreloadKey, getHTML } from '../utils.mjs';

Expand Down
4 changes: 2 additions & 2 deletions test/utils.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { resolve as fsResolve } from 'path';
import { existsSync, promises as fsPromises } from 'fs';
import http from 'http';
import pathe from 'pathe';
import { JSDOM } from 'jsdom';
import rimraf from 'rimraf';
import finalhandler from 'finalhandler';
Expand Down Expand Up @@ -49,7 +49,7 @@ export const deleteDir = path => {

export const getHTML = (path = '') => {
// eslint-disable-next-line security/detect-non-literal-fs-filename
return fsPromises.readFile(fsResolve(path, 'index.html'), 'utf-8');
return fsPromises.readFile(pathe.resolve(path, 'index.html'), 'utf-8');
};

export const startStaticServer = async (dist, port, hostname = 'localhost') => {
Expand Down
2 changes: 1 addition & 1 deletion vitest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'path';
import path from 'pathe';
import { defineConfig } from 'vitest/config';

export default defineConfig({
Expand Down