Skip to content

Commit

Permalink
fix: node path import (#32)
Browse files Browse the repository at this point in the history
* fix: replace node: imports
  • Loading branch information
zhongliang02 authored Nov 19, 2024
1 parent 609df8b commit 5c57c19
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 22 deletions.
4 changes: 2 additions & 2 deletions apps/docs/.vitepress/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'node:fs'
import path from 'node:path'
import fs from 'fs'
import path from 'path'

export const scanDir = (dir: string) => {
let res = fs.readdirSync(path.resolve(__dirname, `../${dir}`)).filter(item => !item.startsWith('.')) as string[]
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { resolve } = require("node:path");
const { resolve } = require("path");

const project = resolve(process.cwd(), "tsconfig.json");

Expand Down
5 changes: 2 additions & 3 deletions packages/safe-fs/src/__tests__/fs.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import fs from 'node:fs'
import path from 'node:path'

import fs from 'fs'
import { vol } from 'memfs'
import path from 'path'
import { beforeEach, describe, expect, it } from 'vitest'

import { createGetter } from '@/getter'
Expand Down
2 changes: 1 addition & 1 deletion packages/safe-fs/src/getter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from 'node:fs'
import fs from 'fs'

import PARAMS_TO_SANITIZE from '@/params'
import { sanitizePath } from '@/sanitizers'
Expand Down
2 changes: 1 addition & 1 deletion packages/safe-fs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @packageDocumentation
*/

import * as fs from 'node:fs'
import * as fs from 'fs'

import { createGetter } from '@/getter'

Expand Down
4 changes: 2 additions & 2 deletions packages/safe-fs/src/sanitizers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PathLike } from 'node:fs'
import path from 'node:path'
import { PathLike } from 'fs'
import path from 'path'

const LEADING_DOT_SLASH_REGEX = /^(\.\.(\/|\\|$))+/

Expand Down
2 changes: 1 addition & 1 deletion packages/safe-fs/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'node:path'
import path from 'path'

export default {
resolve: {
Expand Down
4 changes: 2 additions & 2 deletions packages/safe-fs/vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { vi } from 'vitest'

vi.mock('node:fs', async () => {
vi.mock('fs', async () => {
const memfs: { fs: typeof fs } = await vi.importActual('memfs')

return {
Expand All @@ -10,7 +10,7 @@ vi.mock('node:fs', async () => {
}
})

vi.mock('node:fs/promises', async () => {
vi.mock('fs/promises', async () => {
const memfs: { fs: typeof fs } = await vi.importActual('memfs')

return {
Expand Down
2 changes: 1 addition & 1 deletion packages/validators/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opengovsg/starter-kitty-validators",
"version": "1.2.7",
"version": "1.2.8",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
Expand Down
3 changes: 1 addition & 2 deletions packages/validators/src/__tests__/path.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import path from 'node:path'

import path from 'path'
import { describe, expect, it } from 'vitest'
import { ZodError } from 'zod'

Expand Down
3 changes: 1 addition & 2 deletions packages/validators/src/path/options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import path from 'node:path'

import path from 'path'
import { z } from 'zod'

/**
Expand Down
3 changes: 1 addition & 2 deletions packages/validators/src/path/schema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import path from 'node:path'

import path from 'path'
import { z } from 'zod'

import { ParsedPathValidatorOptions } from '@/path/options'
Expand Down
2 changes: 1 addition & 1 deletion packages/validators/src/path/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'node:path'
import path from 'path'

export const isSafePath = (absPath: string, basePath: string): boolean => {
// check for poison null bytes
Expand Down
2 changes: 1 addition & 1 deletion packages/validators/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path from 'node:path'
import path from 'path'

export default {
resolve: {
Expand Down

0 comments on commit 5c57c19

Please sign in to comment.