Skip to content

Commit

Permalink
Improve dts_cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
gologames committed Jul 30, 2019
1 parent 3ad327e commit 0541b0e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions dts_cleaner.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict';
const fs = require('fs');
var in_path = 'packages/survey-pdf/survey.pdf.d.ts';
var out_path = 'packages/survey-pdf/survey.pdf.d.ts_clean';
var path = 'packages/survey-pdf/survey.pdf.d.ts';
var modules = new Set();
var lines = fs.readFileSync(in_path, 'utf-8').split('\n');
var lines = fs.readFileSync(path, 'utf-8').split('\n');
fs.unlinkSync(path);
lines.forEach((line) => {
var reg = /(import\s*){(.*)}(.*)/;
var res = line.match(reg);
if (!res) {
fs.appendFileSync(out_path, line + '\n');
fs.appendFileSync(path, line + '\n');
return;
}
var sp = res[2].split(/,\s*/);
Expand All @@ -21,8 +21,6 @@ lines.forEach((line) => {
}
}
if (imp_part !== '') {
fs.appendFileSync(out_path, res[1] + '{ ' + imp_part + ' }' + res[3] + '\n');
fs.appendFileSync(path, res[1] + '{ ' + imp_part + ' }' + res[3] + '\n');
}
});
fs.unlinkSync(in_path);
fs.renameSync(out_path, in_path);
});

0 comments on commit 0541b0e

Please sign in to comment.