Skip to content

Commit

Permalink
Switch to gulpfile.mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
fasttime committed Mar 30, 2024
1 parent 430ea41 commit c9859aa
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 25 deletions.
58 changes: 33 additions & 25 deletions gulpfile.js → gulpfile.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
'use strict';
import { rm } from 'fs/promises';
import gulp from 'gulp';
import { dirname, join } from 'path';
import syncReadable from 'sync-readable';
import { fileURLToPath } from 'url';

const { parallel, series, src, task } = require('gulp');
const { parallel, series, src, task } = gulp;

task
(
'clean',
async () =>
{
const { promises: { rm } } = require('fs');

const options = { force: true, recursive: true };
await rm('coverage', options);
},
Expand All @@ -17,17 +19,20 @@ task
task
(
'lint',
() =>
{
const gulpESLintNew = require('gulp-eslint-new');
syncReadable
(
async () =>
{
const { default: gulpESLintNew } = await import('gulp-eslint-new');

const stream =
src(['*.js', 'example/*.js', 'lib/*.{js,ts}', 'test/**/*.{js,ts}'])
.pipe(gulpESLintNew({ configType: 'flat', warnIgnored: true }))
.pipe(gulpESLintNew.format('compact'))
.pipe(gulpESLintNew.failAfterError());
return stream;
},
const stream =
src(['*.{js,mjs}', 'example/*.js', 'lib/*.{js,ts}', 'test/**/*.{js,ts}'])
.pipe(gulpESLintNew({ configType: 'flat', warnIgnored: true }))
.pipe(gulpESLintNew.format('compact'))
.pipe(gulpESLintNew.failAfterError());
return stream;
},
),
);

task
Expand All @@ -36,7 +41,8 @@ task
async () =>
{
const { default: c8js } = await import('c8js');
const mochaPath = require.resolve('mocha/bin/mocha');
const mochaPath = fileURLToPath(import.meta.resolve('mocha/bin/mocha'));

await c8js
(
mochaPath,
Expand All @@ -60,21 +66,23 @@ task

function tsTest(tsVersion, tsPkgName)
{
async function task() // eslint-disable-line require-await
async function task()
{
const { dirname, join } = require('path');
const
{
createDiagnosticReporter,
createProgram,
getPreEmitDiagnostics,
parseJsonConfigFileContent,
readConfigFile,
sys,
default:
{
createDiagnosticReporter,
createProgram,
getPreEmitDiagnostics,
parseJsonConfigFileContent,
readConfigFile,
sys,
},
} =
require(tsPkgName);
await import(tsPkgName);

const pkgPath = __dirname;
const pkgPath = dirname(fileURLToPath(import.meta.url));
const tsConfigPath = join(pkgPath, 'test/tsconfig.json');
const tsConfig = readConfigFile(tsConfigPath, sys.readFile);
const basePath = dirname(tsConfigPath);
Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"globals": "^15.0.0",
"gulp": "^5.0.0",
"mocha": "^9.2.2",
"sync-readable": "^0.0.2",
"typescript": "~5.4.3",
"typescript_4.6": "npm:typescript@4.6",
"typescript_5": "npm:typescript@5",
Expand Down

0 comments on commit c9859aa

Please sign in to comment.