Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added 'clean-and-run-downlevel-dts' script for running 'clean', 'do…
…wnlevel-dts', 'copy' steps for downlevel-dts output directory ('./ts3.5'). - Added generated 'downleveled dts' files (keeping this in the git cache since we're already keeping the library's artifacts there - more consistent).
- Loading branch information
Showing
3 changed files
with
103 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* @script clean-and-run-downlevel-dts.js | ||
* @description Removes '{repo-root}/ts3.5' directory, re-creates it, runs | ||
* `npm run downlevel-dts` from repo-root, and copies the root tsconfig.json file into new directory. | ||
*/ | ||
const fs = require('fs').promises, | ||
path = require('path'), | ||
{spawn} = require('child_process'), | ||
|
||
{log, warn, error} = console, | ||
|
||
rootDir = path.join(__dirname, '..'), | ||
outputDir = path.resolve(path.join(__dirname, '../ts3.5')), | ||
|
||
tsConfigFilePath = path.join(rootDir, 'tsconfig.json'), | ||
tsConfigOutFilePath = path.join(outputDir, 'tsconfig.json'); | ||
|
||
(async () => | ||
fs.rmdir(outputDir, {recursive: true}) | ||
|
||
.then(() => fs.mkdir(outputDir)) | ||
|
||
.then(() => fs.copyFile(tsConfigFilePath, tsConfigOutFilePath)) | ||
|
||
// Run downlevel-dts | ||
.then(() => new Promise((resolve, reject) => { | ||
|
||
// Start downlevel-dts package script | ||
const subProcess = spawn('npm', ['run', 'downlevel-dts'], {cwd: rootDir}); | ||
|
||
// Log child process buffer data as `string` | ||
subProcess.stdout.on('data', data => log(data.toString().trim() + '\n')); | ||
|
||
// Log stderr, child process, buffer data as a `string` | ||
subProcess.stderr.on('data', data => warn(data.toString().trim() + '\n')); | ||
|
||
// Handle process end | ||
subProcess.on('close', (code) => code !== 0 ? | ||
reject(`Child process existed with code ${code}.\n`) : | ||
resolve('Process completed successfully.\n') | ||
); | ||
|
||
// Catch process start errors | ||
subProcess.on('error', reject); | ||
})) | ||
|
||
)().then(log, error); |