Socket
Socket
Sign inDemoInstall

tsc-watch

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsc-watch - npm Package Compare versions

Comparing version 1.0.19 to 1.0.20

5

CHANGELOG.md
# @gilamran/tsc-watch CHANGELOG
## v1.0.20 - 16/04/2018
* Fixed ignoring the last arg
* Added `--noColors` argument
* Added `--noClearScreen` argument
## v1.0.19 - 8/04/2018

@@ -4,0 +9,0 @@ * Fixed passing compilation when using --pretty param (Thanks to @tomaba)

69

lib/tsc-watch.js

@@ -42,3 +42,3 @@ #!/usr/bin/env node

function print(lines) {
return lines.forEach(line => console.log(color(line)));
return lines.forEach(line => console.log(noColors ? line : color(line)));
}

@@ -50,19 +50,19 @@

function cleanArgs(inputArgs) {
return inputArgs
function processArgs(inputArgs) {
const result = inputArgs
.splice(2)
.filter(arg => arg.toLowerCase() !== '-w')
.filter(arg => arg.toLowerCase() !== '--watch')
.filter(arg => arg.toLowerCase() !== '--nocolors')
.filter(arg => arg.toLowerCase() !== '--noclearscreen')
.filter(arg => arg.toLowerCase() !== '--onsuccess')
.filter(arg => arg.toLowerCase() !== '--onfailure')
.filter(arg => arg.toLowerCase() !== '--onfirstsuccess');
result.push('--watch'); // force watch
return result;
}
function getCommandIdx(inputArgs, command) {
const idx = inputArgs.indexOf(command);
if (idx > -1 && idx + 1 < inputArgs.length) {
return idx;
} else {
return -1;
}
return inputArgs.indexOf(command);
}

@@ -73,3 +73,5 @@

const parts = fullCommand.split(' ').filter(a => a.length > 0);
return spawn(parts[0], parts.slice(1), { stdio: 'inherit' })
return spawn(parts[0], parts.slice(1), {
stdio: 'inherit'
})
}

@@ -104,30 +106,21 @@ }

let allArgs = process.argv;
// onSuccess
let onSuccessCommandIdx = getCommandIdx(allArgs, '--onSuccess');
let onSuccessCommand = null;
if (onSuccessCommandIdx > -1) {
onSuccessCommand = allArgs[onSuccessCommandIdx + 1];
allArgs.splice(onSuccessCommandIdx, 2)
function getCustomeCommand(commandStr) {
const allArgs = process.argv;
let onCommandIdx = getCommandIdx(allArgs, commandStr);
let resultCommand = null;
if (onCommandIdx > -1) {
resultCommand = allArgs[onCommandIdx + 1];
allArgs.splice(onCommandIdx, 2)
}
return resultCommand;
}
// onFirstSuccess
let onFirstSuccessCommandIdx = getCommandIdx(allArgs, '--onFirstSuccess');
let onFirstSuccessCommand = null;
if (onFirstSuccessCommandIdx > -1) {
onFirstSuccessCommand = allArgs[onFirstSuccessCommandIdx + 1];
allArgs.splice(onFirstSuccessCommandIdx, 2)
}
const onFirstSuccessCommand = getCustomeCommand('--onFirstSuccess');
const onSuccessCommand = getCustomeCommand('--onSuccess');
const onFailureCommand = getCustomeCommand('--onFailure');
const noColors = getCommandIdx(process.argv, '--noColors') > -1;
const noClearScreen = getCommandIdx(process.argv, '--noClearScreen') > -1;
// onFailure
let onFailureCommandIdx = getCommandIdx(allArgs, '--onFailure');
let onFailureCommand = null;
if (onFailureCommandIdx > -1) {
onFailureCommand = allArgs[onFailureCommandIdx + 1];
allArgs.splice(onFailureCommandIdx, 2)
}
const args = processArgs(process.argv);
let args = cleanArgs(allArgs);
args.push('--watch'); // force watch
const bin = require.resolve('typescript/bin/tsc');

@@ -140,5 +133,5 @@ const tscProcess = spawn(bin, [...args]);

.filter(a => a.length > 0)
// .filter(a => a !== '\r')
.map(a => a.replace(typescriptWatchCommandRegex, newAdditionToSyntax));
.map(a => a.replace(typescriptWatchCommandRegex, newAdditionToSyntax))
.map(a => noClearScreen ? a.replace(/\x1Bc/, '---------------------------------------------\n') : a);
print(lines);

@@ -195,3 +188,3 @@ const cleanLines = removeColors(lines);

const Signal = {
send: typeof process.send === 'function' ? (...e) => process.send(...e) : () => { },
send: typeof process.send === 'function' ? (...e) => process.send(...e) : () => {},
_successStr: 'first_success',

@@ -198,0 +191,0 @@ emitSuccess: () => {

{
"name": "tsc-watch",
"version": "1.0.19",
"version": "1.0.20",
"description": "The TypeScript compiler with onSuccess command",

@@ -5,0 +5,0 @@ "scripts": {

@@ -7,2 +7,4 @@ # The TypeScript compiler with `--watch` and a new onSuccess argument

- `--onFailure COMMAND` - The `COMMAND` will be executed on failed TypeScript compilation.
- `--noColors` - `tsc-watch` colors the output with green on success, and in red on failiure. Add this argument to prevent that.
- `--noClearScreen` - `typescript` started clearing the console before each compilation, Add this argument to prevent it.

@@ -9,0 +11,0 @@ ## Install

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