diff --git a/.gulp.json b/.gulp.json new file mode 100644 index 0000000..6cdb49a --- /dev/null +++ b/.gulp.json @@ -0,0 +1,5 @@ +{ + "flags": { + "gulpfile": "gulpfile.cjs" + } +} diff --git a/etc/tsconfig.json b/etc/tsconfig.json index 46e877c..c074fd7 100644 --- a/etc/tsconfig.json +++ b/etc/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "../tsconfig.json", "include": [ - "../*.ts", "../src/**/*.ts", "../test/**/*.ts" ] diff --git a/gulpfile.ts b/gulpfile.cjs similarity index 73% rename from gulpfile.ts rename to gulpfile.cjs index 56a2c73..cc9c001 100644 --- a/gulpfile.ts +++ b/gulpfile.cjs @@ -1,19 +1,18 @@ -import {spawn, SpawnOptions} from 'child_process'; -import * as del from 'del'; -import {promises} from 'fs'; -import * as gulp from 'gulp'; -import * as replace from 'gulp-replace'; -import {delimiter, normalize, resolve} from 'path'; +const {spawn} = require('child_process'); +const del = require('del'); +const {promises} = require('fs'); +const {dest, series, src, task, watch} = require('gulp'); +const replace = require('gulp-replace'); +const {delimiter, normalize, resolve} = require('path'); -/** The file patterns providing the list of source files. */ -const sources: string[] = ['*.ts', 'src/**/*.ts', 'test/**/*.ts']; - -// Shortcuts. -const {dest, series, src, task, watch} = gulp; -const {copyFile} = promises; +/** + * The file patterns providing the list of source files. + * @type {string[]} + */ +const sources = ['src/**/*.ts', 'test/**/*.ts']; // Initialize the build system. -const _path = process.env.PATH ?? ''; +const _path = 'PATH' in process.env ? process.env.PATH : ''; const _vendor = resolve('node_modules/.bin'); if (!_path.includes(_vendor)) process.env.PATH = `${_vendor}${delimiter}${_path}`; @@ -35,8 +34,8 @@ task('coverage', () => _exec('coveralls', ['var/lcov.info'])); /** Builds the documentation. */ task('doc', async () => { - for (const path of ['CHANGELOG.md', 'LICENSE.md']) await copyFile(path, `doc/about/${path.toLowerCase()}`); - await _exec('typedoc', ['--gaID', process.env.GOOGLE_ANALYTICS_ID!, '--options', 'etc/typedoc.json', '--tsconfig', 'src/tsconfig.json']); + for (const path of ['CHANGELOG.md', 'LICENSE.md']) await promises.copyFile(path, `doc/about/${path.toLowerCase()}`); + await _exec('typedoc', ['--gaID', process.env.GOOGLE_ANALYTICS_ID, '--options', 'etc/typedoc.json', '--tsconfig', 'src/tsconfig.json']); await _exec('mkdocs', ['build', '--config-file=doc/mkdocs.yaml']); return del(['doc/about/changelog.md', 'doc/about/license.md', 'web/mkdocs.yaml']); }); @@ -75,12 +74,12 @@ task('default', task('build')); /** * Spawns a new process using the specified command. - * @param command The command to run. - * @param args The command arguments. - * @param options The settings to customize how the process is spawned. - * @return Completes when the command is finally terminated. + * @param {string} command The command to run. + * @param {string[]} args The command arguments. + * @param {object} options The settings to customize how the process is spawned. + * @return {Promise} Completes when the command is finally terminated. */ -function _exec(command: string, args: string[] = [], options: SpawnOptions = {}): Promise { +function _exec(command, args = [], options = {}) { return new Promise((fulfill, reject) => spawn(normalize(command), args, {shell: true, stdio: 'inherit', ...options}) .on('close', code => code ? reject(new Error(`${command}: ${code}`)) : fulfill()) );