gulp-tsconfig-update
Advanced tools
Comparing version 1.0.9 to 1.1.0
@@ -7,5 +7,3 @@ ///<reference path="../typings/bundle.d.ts"/> | ||
var through = require("through"); | ||
var map = require("map-stream"); | ||
var PluginError = gutil.PluginError; | ||
var RcLoader = require("rcloader"); | ||
function defaultTsConfig() { | ||
@@ -17,5 +15,8 @@ var initiated = require("./_tsconfig.json"); | ||
pluginOptions = pluginOptions || {}; | ||
var tsConfigPath = pluginOptions.configFile || "./tsconfig.json"; | ||
var tsConfigPath = "./tsconfig.json"; | ||
var tsConfig; | ||
if (fs.existsSync(tsConfigPath)) { | ||
if (pluginOptions.defaultConfig) { | ||
tsConfig = pluginOptions.defaultConfig; | ||
} | ||
else if (fs.existsSync(tsConfigPath)) { | ||
tsConfig = JSON.parse(fs.readFileSync(tsConfigPath, "utf-8")); | ||
@@ -22,0 +23,0 @@ } |
{ | ||
"name": "gulp-tsconfig-update", | ||
"version": "1.0.9", | ||
"version": "1.1.0", | ||
"description": "A gulp plugin to update `files` property in tsconfig.json by `gulp.src`.", | ||
@@ -37,6 +37,4 @@ "main": "index.js", | ||
"gulp-util": "^3.0.6", | ||
"map-stream": "0.0.6", | ||
"rcloader": "^0.1.4", | ||
"through": "^2.3.8" | ||
} | ||
} |
# gulp-tsconfig-update | ||
[![Circle CI](https://circleci.com/gh/laco0416/gulp-tsconfig-update.svg?style=svg)](https://circleci.com/gh/laco0416/gulp-tsconfig-update) | ||
[![Build Status](https://travis-ci.org/laco0416/gulp-tsconfig-update.svg)](https://travis-ci.org/laco0416/gulp-tsconfig-update) | ||
@@ -29,17 +29,22 @@ A gulp plugin to update `files` property in tsconfig.json by `gulp.src` glob. | ||
* If `./tsconfig.json` doesn't exist, this plugin will generate the file with default options like below. | ||
* If `./tsconfig.json` doesn't exist, this plugin will generate the file similar to that created by `tsc --init`. | ||
* You can use user-defined default config. | ||
```js | ||
var gulp = require("gulp"); | ||
var tsConfig = require('gulp-tsconfig-update'); | ||
gulp.task('tsConfig', function() { | ||
return gulp.src("./src/**/*.ts") | ||
.pipe(tsConfig({ | ||
defaultConfig: { | ||
compilerOptions: { | ||
module: "commonjs", | ||
target: "es5", | ||
noImplicitAny: true | ||
} | ||
} | ||
})); | ||
}); | ||
``` | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"module": "commonjs", | ||
"declaration": false, | ||
"noImplicitAny": true, | ||
"removeComments": false, | ||
"noLib": false, | ||
"preserveConstEnums": false, | ||
"suppressImplicitAnyIndexErrors": false | ||
} | ||
} | ||
``` |
@@ -13,5 +13,3 @@ ///<reference path="../typings/bundle.d.ts"/> | ||
let map: any = require("map-stream"); | ||
let PluginError: any = gutil.PluginError; | ||
let RcLoader: any = require("rcloader"); | ||
@@ -26,7 +24,12 @@ function defaultTsConfig(): model.TsConfig { | ||
let tsConfigPath = pluginOptions.configFile || "./tsconfig.json"; | ||
let tsConfigPath = "./tsconfig.json"; | ||
let tsConfig: model.TsConfig; | ||
if (fs.existsSync(tsConfigPath)) { | ||
if (pluginOptions.defaultConfig) { | ||
// user defined default config | ||
tsConfig = pluginOptions.defaultConfig; | ||
} else if (fs.existsSync(tsConfigPath)) { | ||
// existing config | ||
tsConfig = <model.TsConfig>JSON.parse(fs.readFileSync(tsConfigPath, "utf-8")); | ||
} else { | ||
// default config | ||
tsConfig = defaultTsConfig(); | ||
@@ -52,3 +55,3 @@ } | ||
tsConfig.files = tsFiles.map((file)=> { | ||
return file.path.replace(file.cwd, ".").replace(/\\/g,"/"); | ||
return file.path.replace(file.cwd, ".").replace(/\\/g, "/"); | ||
}); | ||
@@ -55,0 +58,0 @@ fs.writeFileSync(tsConfigPath, JSON.stringify(tsConfig, null, 4), "utf-8"); |
declare module model { | ||
interface PluginOption { | ||
configFile: string; | ||
defaultConfig?: TsConfig; | ||
} | ||
@@ -5,0 +5,0 @@ |
@@ -17,4 +17,5 @@ ///<reference path="../typings/bundle.d.ts"/> | ||
"./src2/**/*.ts" | ||
]) | ||
.pipe(tsConfig()); | ||
]).pipe(tsConfig({ | ||
defaultConfig: require("./_tsconfig.json") | ||
})); | ||
}); | ||
@@ -21,0 +22,0 @@ |
@@ -8,3 +8,3 @@ var assert = require("chai").assert; | ||
var defaultConfig = require("../lib/_tsconfig.json"); | ||
var defaultConfig = require("./_tsconfig.json"); | ||
@@ -11,0 +11,0 @@ var files = [ |
9057
3
19
232
50
- Removedmap-stream@0.0.6
- Removedrcloader@^0.1.4
- Removedlodash@3.10.1(transitive)
- Removedlodash.clonedeep@4.5.0(transitive)
- Removedmap-stream@0.0.6(transitive)
- Removedrcfinder@0.1.9(transitive)
- Removedrcloader@0.1.4(transitive)