| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f2c2e8a commit 27e9fdd
12 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | #!/usr/bin/env node | |
| 2 | 2 | ||
| 3 | - import fs from 'fs-extra' | ||
| 3 | + import fs from 'node:fs/promises' | ||
| 4 | 4 | import path from 'path' | |
| 5 | 5 | ||
| 6 | 6 | import prettyHrtime from 'pretty-hrtime' | |
@@ -286,10 +286,14 @@ function css(css, file) { | |||
| 286 | 286 | }) | |
| 287 | 287 | ||
| 288 | 288 | async function outputFile(file, string) { | |
| 289 | - const fileExists = await fs.pathExists(file) | ||
| 289 | + const fileExists = await fs.access(file).then( | ||
| 290 | + () => true, | ||
| 291 | + () => false, | ||
| 292 | + ) | ||
| 290 | 293 | const currentValue = fileExists ? await fs.readFile(file, 'utf8') : null | |
| 291 | 294 | if (currentValue === string) return | |
| 292 | - return fs.outputFile(file, string) | ||
| 295 | + await fs.mkdir(path.dirname(file), { recursive: true }) | ||
| 296 | + return fs.writeFile(file, string) | ||
| 293 | 297 | } | |
| 294 | 298 | } | |
| 295 | 299 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,7 +20,6 @@ | |||
| 20 | 20 | "dependencies": { | |
| 21 | 21 | "chokidar": "^3.3.0", | |
| 22 | 22 | "dependency-graph": "^1.0.0", | |
| 23 | - "fs-extra": "^11.0.0", | ||
| 24 | 23 | "picocolors": "^1.0.0", | |
| 25 | 24 | "postcss-load-config": "^5.0.0", | |
| 26 | 25 | "postcss-reporter": "^7.0.0", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | import test from 'ava' | |
| 2 | 2 | ||
| 3 | - import fs from 'fs-extra' | ||
| 3 | + import fs from 'node:fs/promises' | ||
| 4 | 4 | import path from 'path' | |
| 5 | 5 | ||
| 6 | 6 | import cli from './helpers/cli.js' | |
@@ -20,7 +20,12 @@ test('--ext works', async (t) => { | |||
| 20 | 20 | ]) | |
| 21 | 21 | t.falsy(error, stderr) | |
| 22 | 22 | ||
| 23 | - t.truthy(await fs.pathExists(path.join(dir, 'a.css'))) | ||
| 23 | + t.truthy( | ||
| 24 | + await fs.access(path.join(dir, 'a.css')).then( | ||
| 25 | + () => true, | ||
| 26 | + () => false, | ||
| 27 | + ), | ||
| 28 | + ) | ||
| 24 | 29 | }) | |
| 25 | 30 | ||
| 26 | 31 | test('--ext works with no leading dot', async (t) => { | |
@@ -37,5 +42,10 @@ test('--ext works with no leading dot', async (t) => { | |||
| 37 | 42 | ]) | |
| 38 | 43 | t.falsy(error, stderr) | |
| 39 | 44 | ||
| 40 | - t.truthy(await fs.pathExists(path.join(dir, 'a.css'))) | ||
| 45 | + t.truthy( | ||
| 46 | + await fs.access(path.join(dir, 'a.css')).then( | ||
| 47 | + () => true, | ||
| 48 | + () => false, | ||
| 49 | + ), | ||
| 50 | + ) | ||
| 41 | 51 | }) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,8 +1,10 @@ | |||
| 1 | - import fs from 'fs-extra' | ||
| 1 | + import fs from 'node:fs/promises' | ||
| 2 | 2 | ||
| 3 | 3 | Promise.all([ | |
| 4 | - fs.emptyDir('./test/fixtures/.tmp/'), | ||
| 5 | - fs.remove('./coverage'), | ||
| 4 | + fs | ||
| 5 | + .rm('./test/fixtures/.tmp/', { recursive: true, force: true }) | ||
| 6 | + .then(() => fs.mkdir('./test/fixtures/.tmp/', { recursive: true })), | ||
| 7 | + fs.rm('./coverage', { recursive: true, force: true }), | ||
| 6 | 8 | ]).catch((err) => { | |
| 7 | 9 | console.error(err) | |
| 8 | 10 | process.exit(1) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,18 +1,24 @@ | |||
| 1 | - import fs from 'fs-extra' | ||
| 1 | + import fs from 'node:fs/promises' | ||
| 2 | 2 | import path from 'path' | |
| 3 | 3 | import { glob } from 'tinyglobby' | |
| 4 | 4 | ||
| 5 | 5 | import tmp from './tmp.js' | |
| 6 | 6 | ||
| 7 | - export default function (config, fixtures = '**/*', extension = 'cjs') { | ||
| 7 | + export default async function (config, fixtures = '**/*', extension = 'cjs') { | ||
| 8 | 8 | const dir = tmp() | |
| 9 | 9 | ||
| 10 | - return Promise.all([ | ||
| 11 | - glob(fixtures, { cwd: 'test/fixtures' }).then((list) => { | ||
| 12 | - return list.map((item) => { | ||
| 13 | - return fs.copy(path.join('test/fixtures', item), path.join(dir, item)) | ||
| 14 | - }) | ||
| 10 | + await fs.mkdir(dir, { recursive: true }) | ||
| 11 | + | ||
| 12 | + const list = await glob(fixtures, { cwd: 'test/fixtures' }) | ||
| 13 | + | ||
| 14 | + await Promise.all([ | ||
| 15 | + ...list.map(async (item) => { | ||
| 16 | + const dest = path.join(dir, item) | ||
| 17 | + await fs.mkdir(path.dirname(dest), { recursive: true }) | ||
| 18 | + await fs.copyFile(path.join('test/fixtures', item), dest) | ||
| 15 | 19 | }), | |
| 16 | - fs.outputFile(path.join(dir, `postcss.config.${extension}`), config), | ||
| 17 | - ]).then(() => dir) | ||
| 20 | + fs.writeFile(path.join(dir, `postcss.config.${extension}`), config), | ||
| 21 | + ]) | ||
| 22 | + | ||
| 23 | + return dir | ||
| 18 | 24 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - import fs from 'fs-extra' | ||
| 1 | + import fs from 'node:fs/promises' | ||
| 2 | 2 | ||
| 3 | 3 | export default function (path) { | |
| 4 | 4 | return fs.readFile(path, 'utf8').then( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | import test from 'ava' | |
| 2 | - import fs from 'fs-extra' | ||
| 2 | + import fs from 'node:fs/promises' | ||
| 3 | 3 | ||
| 4 | 4 | import cli from './helpers/cli.js' | |
| 5 | 5 | import tmp from './helpers/tmp.js' | |
@@ -35,7 +35,12 @@ test('--map generates external sourcemaps', async (t) => { | |||
| 35 | 35 | ||
| 36 | 36 | t.falsy(error, stderr) | |
| 37 | 37 | ||
| 38 | - t.truthy(await fs.pathExists(output.replace('.css', '.css.map'))) | ||
| 38 | + t.truthy( | ||
| 39 | + await fs.access(output.replace('.css', '.css.map')).then( | ||
| 40 | + () => true, | ||
| 41 | + () => false, | ||
| 42 | + ), | ||
| 43 | + ) | ||
| 39 | 44 | }) | |
| 40 | 45 | ||
| 41 | 46 | test('--no-map disables internal sourcemaps', async (t) => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | import test from 'ava' | |
| 2 | 2 | ||
| 3 | - import fs from 'fs-extra' | ||
| 3 | + import fs from 'node:fs/promises' | ||
| 4 | 4 | import path from 'path' | |
| 5 | 5 | ||
| 6 | 6 | import cli from './helpers/cli.js' | |
@@ -12,9 +12,10 @@ test('--replace works', async (t) => { | |||
| 12 | 12 | ||
| 13 | 13 | const output = path.join(dir, 'output.css') | |
| 14 | 14 | ||
| 15 | + await fs.mkdir(dir, { recursive: true }) | ||
| 15 | 16 | await Promise.all([ | |
| 16 | - fs.copy('test/fixtures/import.css', output), | ||
| 17 | - fs.copy('test/fixtures/a.css', path.join(dir, 'a.css')), | ||
| 17 | + fs.copyFile('test/fixtures/import.css', output), | ||
| 18 | + fs.copyFile('test/fixtures/a.css', path.join(dir, 'a.css')), | ||
| 18 | 19 | ]) | |
| 19 | 20 | ||
| 20 | 21 | const { error, stderr } = await cli([ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | import test from 'ava' | |
| 2 | 2 | ||
| 3 | - import fs from 'fs-extra' | ||
| 3 | + import { createReadStream } from 'node:fs' | ||
| 4 | 4 | import path from 'path' | |
| 5 | 5 | import { exec } from 'child_process' | |
| 6 | 6 | ||
@@ -24,5 +24,5 @@ test.cb('reads from stdin', (t) => { | |||
| 24 | 24 | }, | |
| 25 | 25 | ) | |
| 26 | 26 | ||
| 27 | - fs.createReadStream('test/fixtures/a.css').pipe(cp.stdin) | ||
| 27 | + createReadStream('test/fixtures/a.css').pipe(cp.stdin) | ||
| 28 | 28 | }) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | import test from 'ava' | |
| 2 | 2 | ||
| 3 | - import fs from 'fs-extra' | ||
| 3 | + import { createReadStream } from 'node:fs' | ||
| 4 | 4 | import path from 'path' | |
| 5 | 5 | import { exec } from 'child_process' | |
| 6 | 6 | ||
@@ -23,5 +23,5 @@ test.cb('writes to stdout', (t) => { | |||
| 23 | 23 | }, | |
| 24 | 24 | ) | |
| 25 | 25 | ||
| 26 | - fs.createReadStream('./test/fixtures/a.sss').pipe(cp.stdin) | ||
| 26 | + createReadStream('./test/fixtures/a.sss').pipe(cp.stdin) | ||
| 27 | 27 | }) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments