43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
const read = require('@plastichub/fs/read').sync;
|
|
const path = require('path');
|
|
const write = require('@plastichub/fs/write').sync;
|
|
|
|
|
|
const content = read('./shop_errors.txt').split('\n');
|
|
|
|
let api = read('./src/shop/api.ts');
|
|
|
|
var lineReader = require('readline').createInterface({
|
|
input: require('fs').createReadStream('shop_errors.txt')
|
|
});
|
|
|
|
var types = {};
|
|
|
|
lineReader.on('line', function (line) {
|
|
// create a map of the unresolved types
|
|
if (line.indexOf('src/shop/api.ts')) {
|
|
const type = line.split("'")[1];
|
|
if (type) {
|
|
if (!types[type]) {
|
|
types[type] = false;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
String.prototype.replaceAll = function (search, replacement) {
|
|
var target = this;
|
|
return target.split(search).join(replacement);
|
|
};
|
|
|
|
|
|
lineReader.on('close', function (e) {
|
|
for (var t in types) {
|
|
t = t.replace(/[^\x00-\x7F]/g, ""); // non ascii
|
|
t = t.replace(/[\u0000-\u001F\u007F-\u009F]/g, "");//typescript term characters
|
|
t = t.replace(/[\u{0080}-\u{FFFF}]/gu,"");//terminal plugin special characters
|
|
api = api.replaceAll(t, 'any');
|
|
}
|
|
write('./src/shop/api.ts', api);
|
|
});
|