Skip to content

Commit

Permalink
Replace in-house function to remove banner with CLI argument
Browse files Browse the repository at this point in the history
  • Loading branch information
timocov authored Dec 29, 2023
1 parent be890a5 commit 1f39f0d
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions node-scripts/generate-dts.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ fs.readdirSync(pluginsDir).forEach((pluginName) => {

try {
execSync(
`npx dts-bundle-generator -o ${distDir}/${pluginName}.d.ts ${pluginsDir}/${pluginName}/index.ts`,
`npx dts-bundle-generator --no-banner -o ${distDir}/${pluginName}.d.ts ${pluginsDir}/${pluginName}/index.ts`,
);
console.log(`Generated ${pluginName}.d.ts successfully`);

removeLineFromFile(outputFile, '// Generated by dts-bundle-generator');
console.log(`Cleaned up ${pluginName}.d.ts file`);
} catch (error) {
console.error(`Error generating .d.ts for ${pluginName}:`, error);
}
Expand All @@ -39,22 +36,11 @@ try {
console.log(`Generating .d.ts for MAIN`);

execSync(
`npx dts-bundle-generator -o ${distDir}/index.d.ts ./src/index.ts`,
`npx dts-bundle-generator --no-banner -o ${distDir}/index.d.ts ./src/index.ts`,
);
console.log(`Generated d.ts for MAIN successfully`);

removeLineFromFile(outputFile, '// Generated by dts-bundle-generator');
console.log(`Cleaned up MAIN file`);
} catch (error) {
console.error(`Error generating .d.ts for MAIN:`, error);
}

console.log(`Ended after ${((Date.now() - startTime) / 10 / 60).toFixed()}s`);

function removeLineFromFile(filePath, lineStart) {
const fileContent = fs.readFileSync(filePath, 'utf8');
const lines = fileContent.split('\n');
const filteredLines = lines.filter((line) => !line.startsWith(lineStart));

fs.writeFileSync(filePath, filteredLines.join('\n'), 'utf8');
}

0 comments on commit 1f39f0d

Please sign in to comment.