Socket
Socket
Sign inDemoInstall

grunt-ts

Package Overview
Dependencies
Maintainers
5
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-ts - npm Package Compare versions

Comparing version 4.1.0 to 4.1.1

3

CHANGELOG.md

@@ -5,2 +5,5 @@ # Releases

## v4.1.1
* FIX: Support for the Grunt `files` feature had a regression and was not working correctly. (#251). Thanks to @Linowitch for the report. We've built in some assertions to ensure this doesn't happen again.
## v4.1.0

@@ -7,0 +10,0 @@ * FIX: The `reference` property should properly work with Grunt transforms again (#235 + #245). Thanks to @thorseye for the PR and @smfeest for independently reporting.

2

package.json

@@ -5,3 +5,3 @@ {

"description": "Compile and manage your TypeScript project",
"version": "4.1.0",
"version": "4.1.1",
"homepage": "https://github.com/grunt-ts/grunt-ts",

@@ -8,0 +8,0 @@ "repository": {

@@ -971,3 +971,14 @@ # grunt-ts

### Quickstart for debugging Grunt plugins with Node Inspector
Install [Node Inspector](https://github.com/node-inspector/node-inspector) via npm:
`npm install -g node-inspector`
Example command-line to debug a grunt-ts task on Windows:
`node-debug --debug-brk %appdata%\npm\node_modules\grunt-cli\bin\grunt ts:files_testFilesUsedWithDestAsAJSFile`
Set breakpoints in the Chrome dev tools, or use `debugger;` where needed.
### Additional commands

@@ -974,0 +985,0 @@ Update the current `grunt-ts` to be the last known good version (dogfood). Commit message should be `Update LKG`.

@@ -29,3 +29,3 @@ /// <reference path="../../defs/tsd.d.ts"/>

/////////////////////////////////////////////////////////////////
// Fast Compilation
// Fast Compilation
/////////////////////////////////////////////////////////////////

@@ -66,3 +66,3 @@ // Map to store if the cache was cleared after the gruntfile was parsed

}
function compileAllFiles(targetFiles, target, task, targetName) {
function compileAllFiles(targetFiles, target, task, targetName, outFile) {
// Make a local copy so we can modify files without having external side effects

@@ -74,3 +74,3 @@ var files = _.map(targetFiles, function (file) { return file; });

if (cacheClearedOnce[exports.grunt.task.current.target] === undefined) {
// Then clear the cache for this target
// Then clear the cache for this target
clearCache(targetName);

@@ -165,3 +165,11 @@ }

// Target options:
if (target.out) {
if (outFile) {
if (utils.isJavaScriptFile(outFile)) {
args.push('--out', outFile);
}
else {
args.push('--outDir', outFile);
}
}
else if (target.out) {
args.push('--out', target.out);

@@ -181,3 +189,5 @@ }

if (target.dest === 'src') {
console.warn(('WARNING: Destination for target "' + targetName + '" is "src", which is the default. If you have' + ' forgotten to specify a "dest" parameter, please add it. If this is correct, you may wish' + ' to change the "dest" parameter to "src/" or just ignore this warning.').magenta);
console.warn(('WARNING: Destination for target "' + targetName + '" is "src", which is the default. If you have' +
' forgotten to specify a "dest" parameter, please add it. If this is correct, you may wish' +
' to change the "dest" parameter to "src/" or just ignore this warning.').magenta);
}

@@ -188,3 +198,6 @@ if (Array.isArray(target.dest)) {

else if (target.dest.length > 0) {
console.warn((('WARNING: "dest" for target "' + targetName + '" is an array. This is not supported by the' + ' TypeScript compiler or grunt-ts.' + ((target.dest.length > 1) ? ' Only the first "dest" will be used. The' + ' remaining items will be truncated.' : ''))).magenta);
console.warn((('WARNING: "dest" for target "' + targetName + '" is an array. This is not supported by the' +
' TypeScript compiler or grunt-ts.' +
((target.dest.length > 1) ? ' Only the first "dest" will be used. The' +
' remaining items will be truncated.' : ''))).magenta);
args.push('--outDir', target.dest[0]);

@@ -242,2 +255,1 @@ }

exports.compileAllFiles = compileAllFiles;
//# sourceMappingURL=compile.js.map

@@ -10,3 +10,3 @@ /// <reference path="../../defs/tsd.d.ts"/>

var Promise: typeof Promise = require('es6-promise').Promise;
var Promise = require('es6-promise').Promise;
export var grunt: IGrunt = require('grunt');

@@ -40,3 +40,3 @@

/////////////////////////////////////////////////////////////////
// Fast Compilation
// Fast Compilation
/////////////////////////////////////////////////////////////////

@@ -90,3 +90,7 @@

export function compileAllFiles(targetFiles: string[], target: ITargetOptions, task: ITaskOptions, targetName: string): Promise<ICompileResult> {
export function compileAllFiles(targetFiles: string[],
target: ITargetOptions,
task: ITaskOptions,
targetName: string,
outFile: string): Promise<ICompileResult> {

@@ -102,3 +106,3 @@ // Make a local copy so we can modify files without having external side effects

// Then clear the cache for this target
// Then clear the cache for this target
clearCache(targetName);

@@ -203,3 +207,9 @@ }

// Target options:
if (target.out) {
if (outFile) {
if (utils.isJavaScriptFile(outFile)) {
args.push('--out', outFile);
} else {
args.push('--outDir', outFile);
}
} else if (target.out) {
args.push('--out', target.out);

@@ -206,0 +216,0 @@ }

@@ -240,2 +240,12 @@ /// <reference path="../../defs/tsd.d.ts"/>

exports.firstElementWithValue = firstElementWithValue;
function getOrGetFirst(getFrom) {
if (_.isArray(getFrom)) {
if (getFrom.length > 0) {
return getFrom[0];
}
return '';
}
return getFrom;
}
exports.getOrGetFirst = getOrGetFirst;
//# sourceMappingURL=utils.js.map

@@ -83,3 +83,3 @@ /// <reference path="../../defs/tsd.d.ts"/>

/** function for formatting strings
/** function for formatting strings
* ('{0} says {1}','la','ba' ) => 'la says ba'

@@ -140,3 +140,3 @@ */

* @param {RegExp|Function} exclude Defines which files should be excluded.
Can be a RegExp (whole filepath is tested) or a Function which will get the filepath
Can be a RegExp (whole filepath is tested) or a Function which will get the filepath
as an argument and should return true (exclude file) or false (do not exclude).

@@ -152,4 +152,4 @@ * @returns {Array} An array of files

* @param {String} dirPath A path to a directory
* @param {RegExp|Function} exclude Defines which directories should be excluded.
Can be a RegExp (whole dirpath is tested) or a Function which will get the dirpath
* @param {RegExp|Function} exclude Defines which directories should be excluded.
Can be a RegExp (whole dirpath is tested) or a Function which will get the dirpath
as an argument and should return true (exclude dir) or false (do not exclude).

@@ -165,4 +165,4 @@ * @returns {Array} An array of directories

* @param {String} dirPath A path to a directory
* @param {RegExp|Function} exclude Defines which files or directories should be excluded.
Can be a RegExp (whole path is tested) or a Function which will get the path
* @param {RegExp|Function} exclude Defines which files or directories should be excluded.
Can be a RegExp (whole path is tested) or a Function which will get the path
as an argument and should return true (exclude) or false (do not exclude).

@@ -259,1 +259,11 @@ * @param {Boolean} getFiles Whether to get files (true) or directories (false).

}
export function getOrGetFirst(getFrom: string | string[]) : string {
if (_.isArray(getFrom)) {
if (getFrom.length > 0) {
return getFrom[0];
}
return '';
}
return <string>getFrom;
}

@@ -235,3 +235,3 @@ /// <reference path="../defs/tsd.d.ts"/>

// Create a reference file?
var reference = processTemplate(rawTargetConfig.reference);
var reference = processIndividualTemplate(rawTargetConfig.reference);
var referenceFile;

@@ -250,11 +250,13 @@ var referencePath;

if (target.dest) {
if (Array.isArray(target.dest)) {
if (target.dest.length > 0) {
// A dest array is meaningless in TypeScript, so just take
// the first one.
targetout = target.dest[0];
}
// A dest array is meaningless in TypeScript, so just take
// the first one.
targetout = utils.getOrGetFirst(target.dest);
}
else if (target.files) {
var filesKeys = _.keys(target.files);
if (filesKeys.length > filesCompilationIndex && utils.isJavaScriptFile(filesKeys[filesCompilationIndex])) {
targetout = filesKeys[filesCompilationIndex];
}
else if (utils.isJavaScriptFile(target.dest)) {
targetout = target.dest;
else if (filesKeys.length > filesCompilationIndex && target.files[filesKeys[filesCompilationIndex]].dest) {
targetout = utils.getOrGetFirst(target.files[filesKeys[filesCompilationIndex]].dest);
}

@@ -269,3 +271,3 @@ }

if (!!outFile) {
outFile = path.resolve(rawTargetConfig.out);
outFile = path.resolve(outFile);
outFile_d_ts = outFile.replace('.js', '.d.ts');

@@ -294,3 +296,4 @@ }

}
processAllTemplates(rawTargetConfig, rawTargetOptions);
processAllTargetTemplates(rawTargetConfig, rawTargetOptions);
outFile = processIndividualTemplate(outFile);
// Compiles all the files

@@ -308,3 +311,3 @@ // Uses the blind tsc compile task

// Compile the files
return compileModule.compileAllFiles(filesToCompile, target, options, currenttask.target).then(function (result) {
return compileModule.compileAllFiles(filesToCompile, target, options, currenttask.target, outFile).then(function (result) {
// End the timer

@@ -418,3 +421,2 @@ endtime = new Date().getTime();

filesToCompile = grunt.file.expand(currenttask.data.files[filesCompilationIndex].src);
filesCompilationIndex += 1;
}

@@ -427,2 +429,3 @@ else if (currenttask.data.files[target.dest]) {

}
filesCompilationIndex += 1;
}

@@ -593,10 +596,10 @@ // ignore directories, and clear the files of output.d.ts and baseDirFile

}
function processAllTemplates(targetCfg, targetOpt) {
targetCfg.out = processTemplate(targetCfg.out);
targetCfg.outDir = processTemplate(targetCfg.outDir);
targetCfg.reference = processTemplate(targetCfg.reference);
targetOpt.mapRoot = processTemplate(targetOpt.mapRoot);
targetOpt.sourceRoot = processTemplate(targetOpt.sourceRoot);
function processAllTargetTemplates(targetCfg, targetOpt) {
targetCfg.out = processIndividualTemplate(targetCfg.out);
targetCfg.outDir = processIndividualTemplate(targetCfg.outDir);
targetCfg.reference = processIndividualTemplate(targetCfg.reference);
targetOpt.mapRoot = processIndividualTemplate(targetOpt.mapRoot);
targetOpt.sourceRoot = processIndividualTemplate(targetOpt.sourceRoot);
}
function processTemplate(template) {
function processIndividualTemplate(template) {
if (template) {

@@ -603,0 +606,0 @@ return grunt.template.process(template, {});

@@ -305,3 +305,3 @@ /// <reference path="../defs/tsd.d.ts"/>

// Create a reference file?
var reference = processTemplate(rawTargetConfig.reference);
var reference = processIndividualTemplate(rawTargetConfig.reference);
var referenceFile;

@@ -321,10 +321,18 @@ var referencePath;

if (target.dest) {
if (Array.isArray(target.dest)) {
if ((<string[]><any>target.dest).length > 0) {
// A dest array is meaningless in TypeScript, so just take
// the first one.
targetout = (<string[]><any>target.dest)[0];
}
} else if (utils.isJavaScriptFile(target.dest)) {
targetout = target.dest;
// A dest array is meaningless in TypeScript, so just take
// the first one.
targetout = utils.getOrGetFirst(target.dest);
}
else if (target.files) {
var filesKeys = _.keys(target.files);
if (filesKeys.length > filesCompilationIndex &&
utils.isJavaScriptFile(filesKeys[filesCompilationIndex])) {
targetout = filesKeys[filesCompilationIndex];
} else if (filesKeys.length > filesCompilationIndex &&
target.files[filesKeys[filesCompilationIndex]].dest) {
targetout = utils.getOrGetFirst(
// A dest array is meaningless in TypeScript, so just take
// the first one.
target.files[filesKeys[filesCompilationIndex]].dest
);
}

@@ -341,3 +349,3 @@ }

if (!!outFile) {
outFile = path.resolve(rawTargetConfig.out);
outFile = path.resolve(outFile);
outFile_d_ts = outFile.replace('.js', '.d.ts');

@@ -371,3 +379,4 @@ }

processAllTemplates(rawTargetConfig, rawTargetOptions);
processAllTargetTemplates(rawTargetConfig, rawTargetOptions);
outFile = processIndividualTemplate(outFile);

@@ -389,3 +398,3 @@ // Compiles all the files

// Compile the files
return compileModule.compileAllFiles(filesToCompile, target, options, currenttask.target)
return compileModule.compileAllFiles(filesToCompile, target, options, currenttask.target, outFile)
.then((result: compileModule.ICompileResult) => {

@@ -525,3 +534,2 @@ // End the timer

filesToCompile = grunt.file.expand(currenttask.data.files[filesCompilationIndex].src);
filesCompilationIndex += 1;
} else if (currenttask.data.files[target.dest]) {

@@ -532,2 +540,3 @@ filesToCompile = grunt.file.expand(currenttask.data.files[target.dest]);

}
filesCompilationIndex += 1;
}

@@ -740,10 +749,10 @@

function processAllTemplates(targetCfg: ITargetOptions, targetOpt: ITaskOptions) {
targetCfg.out = processTemplate(targetCfg.out);
targetCfg.outDir = processTemplate(targetCfg.outDir);
targetCfg.reference = processTemplate(targetCfg.reference);
targetOpt.mapRoot = processTemplate(targetOpt.mapRoot);
targetOpt.sourceRoot = processTemplate(targetOpt.sourceRoot);
function processAllTargetTemplates(targetCfg: ITargetOptions, targetOpt: ITaskOptions) {
targetCfg.out = processIndividualTemplate(targetCfg.out);
targetCfg.outDir = processIndividualTemplate(targetCfg.outDir);
targetCfg.reference = processIndividualTemplate(targetCfg.reference);
targetOpt.mapRoot = processIndividualTemplate(targetOpt.mapRoot);
targetOpt.sourceRoot = processIndividualTemplate(targetOpt.sourceRoot);
}
function processTemplate(template: string) {
function processIndividualTemplate(template: string) {
if (template) {

@@ -750,0 +759,0 @@ return grunt.template.process(template, {});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc