Comparing version 2.0.1 to 2.1.0
@@ -14,2 +14,4 @@ import Promise = require('pinkie-promise'); | ||
compilerOptions?: CompilerOptions; | ||
filterDefinitions?: boolean; | ||
resolvePaths?: boolean; | ||
} | ||
@@ -16,0 +18,0 @@ export declare function resolve(dir: string): Promise<string>; |
@@ -87,3 +87,3 @@ var fs = require('fs'); | ||
} | ||
return Promise.resolve(sanitizeConfig(data, null, filename, options)); | ||
return Promise.resolve(sanitizeConfig(data, data.files, filename, options)); | ||
} | ||
@@ -96,3 +96,3 @@ exports.resolveConfig = resolveConfig; | ||
} | ||
return sanitizeConfig(data, null, filename, options); | ||
return sanitizeConfig(data, data.files, filename, options); | ||
} | ||
@@ -116,11 +116,21 @@ exports.resolveConfigSync = resolveConfigSync; | ||
} | ||
function sanitizeConfig(data, files, filename, options) { | ||
function sanitizeConfig(data, rawFiles, filename, options) { | ||
if (options === void 0) { options = {}; } | ||
var dirname = path.dirname(filename); | ||
return extend(data, { | ||
compilerOptions: extend(options.compilerOptions, data.compilerOptions), | ||
files: sanitizeFilenames(files || data.files, dirname), | ||
exclude: sanitizeFilenames(data.exclude, dirname) | ||
}); | ||
var sanitize = options.resolvePaths !== false; | ||
var filter = options.filterDefinitions === true; | ||
var compilerOptions = extend(options.compilerOptions, data.compilerOptions); | ||
var tsconfig = extend(data, { compilerOptions: compilerOptions }); | ||
if (rawFiles != null) { | ||
var files = sanitize ? resolvePaths(rawFiles, dirname) : rawFiles; | ||
tsconfig.files = filter ? filterDefinitions(files) : files; | ||
} | ||
if (data.exclude != null) { | ||
tsconfig.exclude = sanitize ? resolvePaths(data.exclude, dirname) : data.exclude; | ||
} | ||
return tsconfig; | ||
} | ||
function filterDefinitions(files) { | ||
return Array.isArray(files) ? files.filter(function (x) { return /\.d\.ts$/.test(x); }) : files; | ||
} | ||
function fileExists(filename) { | ||
@@ -142,7 +152,4 @@ return new Promise(function (resolve, reject) { | ||
} | ||
function sanitizeFilenames(filenames, dirname) { | ||
if (!filenames) { | ||
return []; | ||
} | ||
return uniq(filenames.map(function (filename) { return path.resolve(dirname, filename); })); | ||
function resolvePaths(paths, dirname) { | ||
return paths ? uniq(paths.map(function (x) { return path.resolve(dirname, x); })) : undefined; | ||
} | ||
@@ -149,0 +156,0 @@ function globOptions(filename) { |
@@ -21,4 +21,3 @@ var chai_1 = require('chai'); | ||
path_1.join(__dirname, '../tests/empty/foo/bar.ts') | ||
], | ||
exclude: [] | ||
] | ||
} | ||
@@ -39,4 +38,3 @@ }, | ||
path_1.join(__dirname, '../tests/valid/src/foo.ts') | ||
], | ||
exclude: [] | ||
] | ||
}, | ||
@@ -58,4 +56,3 @@ filename: path_1.join(__dirname, '../tests/valid/tsconfig.json') | ||
path_1.join(__dirname, '../tests/bom/src/bom.ts') | ||
], | ||
exclude: [] | ||
] | ||
}, | ||
@@ -96,4 +93,3 @@ filename: path_1.join(__dirname, '../tests/bom/tsconfig.json') | ||
path_1.join(__dirname, '../tests/cwd/foo.tsx') | ||
], | ||
exclude: [] | ||
] | ||
}, | ||
@@ -106,3 +102,2 @@ filename: path_1.join(__dirname, '../tests/cwd/tsconfig.json') | ||
compilerOptions: {}, | ||
exclude: [], | ||
files: [ | ||
@@ -119,3 +114,2 @@ path_1.join(__dirname, '../tests/glob/src/foo.ts') | ||
compilerOptions: {}, | ||
exclude: [], | ||
files: [ | ||
@@ -139,3 +133,2 @@ path_1.join(__dirname, '../tests/glob-negation/src/foo.ts') | ||
}, | ||
exclude: [], | ||
files: [ | ||
@@ -151,2 +144,5 @@ path_1.join(__dirname, '../tests/glob-multi/a/foo.ts'), | ||
path: path_1.join(__dirname, '../tests/glob-positive-negative'), | ||
options: { | ||
resolvePaths: false | ||
}, | ||
result: { | ||
@@ -162,3 +158,3 @@ compilerOptions: { | ||
files: [ | ||
path_1.join(__dirname, '../tests/glob-positive-negative/foo/bar.ts') | ||
'foo/bar.ts' | ||
], | ||
@@ -168,2 +164,16 @@ filesGlob: ['!foo/**/*.ts', 'foo/bar.ts'] | ||
filename: path_1.join(__dirname, '../tests/glob-positive-negative/tsconfig.json') | ||
}, | ||
{ | ||
path: path_1.join(__dirname, '../tests/mixed'), | ||
options: { | ||
filterDefinitions: true, | ||
resolvePaths: false | ||
}, | ||
result: { | ||
compilerOptions: {}, | ||
files: [ | ||
'bar.d.ts' | ||
] | ||
}, | ||
filename: path_1.join(__dirname, '../tests/mixed/tsconfig.json') | ||
} | ||
@@ -170,0 +180,0 @@ ]; |
{ | ||
"name": "tsconfig", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "TypeScript project file specification + implementation", | ||
@@ -48,3 +48,2 @@ "main": "dist/tsconfig.js", | ||
"array-uniq": "^1.0.2", | ||
"glob": "^5.0.15", | ||
"globby": "^3.0.1", | ||
@@ -51,0 +50,0 @@ "parse-json": "^2.2.0", |
@@ -31,3 +31,5 @@ # TSConfig | ||
* **compilerOptions** Default compiler options to apply on expansion. | ||
* **compilerOptions** Default compiler options to apply on expansion (default: `{}`). | ||
* **filterDefinitions** Return a list files which are only `.d.ts` files (default: `false`). | ||
* **resolvePaths** Resolve paths to absolute and remove duplicate entries (default: `true`). | ||
@@ -34,0 +36,0 @@ ## Contributing |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33100
6
404
51
- Removedglob@^5.0.15