use gulp for typescript compiling to delete migrations folder for each new transpilation

This commit is contained in:
Xymorot 2019-06-23 19:03:16 +02:00
parent 3f51ccca64
commit ba670c31ad
4 changed files with 1186 additions and 4 deletions

39
gulpfile.js Normal file
View File

@ -0,0 +1,39 @@
const { dest, watch } = require('gulp');
const ts = require('gulp-typescript');
const fs = require('fs');
const path = require('path');
const tsProject = ts.createProject('tsconfig.json');
function deleteFolderRecursive(folder) {
if (fs.existsSync(folder)) {
fs.readdirSync(folder).forEach(function(file) {
const currPath = path.resolve(folder, file);
if (fs.lstatSync(currPath).isDirectory()) {
deleteFolderRecursive(currPath);
} else {
fs.unlinkSync(currPath);
}
});
fs.rmdirSync(folder);
}
}
function removeCompiledMigrations() {
const migrationsDir = path.resolve('dist/main/migrations');
deleteFolderRecursive(migrationsDir);
}
function tsc() {
removeCompiledMigrations();
return tsProject
.src()
.pipe(tsProject())
.js.pipe(dest('dist'));
}
exports.tsc = tsc;
exports['tsc:watch'] = () => {
watch('./src/**/*.ts', { ignoreInitial: false }, tsc);
};

1142
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@
"dev": "electron . --enable-logging",
"rebuild": "electron-rebuild -f -b -t prod,dev,optional",
"typeorm:migrate": "typeorm migration:run -c library",
"tsc": "tsc --watch",
"tsc": "gulp tsc:watch",
"webpack": "webpack --watch",
"eslint-check": "eslint --print-config . | eslint-config-prettier-check",
"eslint": "eslint .",
@ -28,6 +28,9 @@
"eslint": "^5.16.0",
"eslint-config-prettier": "^5.0.0",
"eslint-plugin-prettier": "^3.1.0",
"gulp": "^4.0.2",
"gulp-cli": "^2.2.0",
"gulp-typescript": "^5.0.1",
"prettier": "^1.18.2",
"sqlite3": "^4.0.9",
"svelte": "^3.5.1",

View File

@ -13,9 +13,7 @@
{
"name": "typescript-tslint-plugin"
}
],
"rootDir": "src",
"outDir": "dist"
]
},
"include": ["src/**/*"]
}