forked from external-repos/squoosh
* Expose type declarations in libSquoosh npm package * Add comment on why we remove the tsbuildinfo * Fix PreprocessOptions type Resize should require at least one of the width, height. The other options are optional for all preprocessors * Update libSquoosh README to reflect encode changes I also removed requiring `await image.decoded` call before calling preprocess or encode since they decode the image before the operation
27 lines
841 B
JavaScript
27 lines
841 B
JavaScript
const fs = require('fs');
|
|
const del = require('del');
|
|
const path = require('path');
|
|
|
|
const tsOutputDir = path.resolve('..', '.tmp', 'ts', 'libsquoosh');
|
|
const tsOutputSourceDir = path.join(tsOutputDir, 'src');
|
|
const buildDir = path.resolve('build');
|
|
|
|
(async () => {
|
|
await del(path.join(buildDir, '*.d.ts'));
|
|
const files = await fs.promises.readdir(tsOutputSourceDir);
|
|
|
|
const movePromises = [];
|
|
for (const file of files) {
|
|
if (file.endsWith('d.ts') || file.endsWith('d.ts.map')) {
|
|
movePromises.push(
|
|
fs.promises.rename(
|
|
path.join(tsOutputSourceDir, file),
|
|
path.join(buildDir, file),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
// We need to remove `tsconfig.tsbuildinfo` otherwise TS does not emit unchanged `.d.ts` files
|
|
await del([path.join(tsOutputDir, 'tsconfig.tsbuildinfo')], { force: true });
|
|
})();
|