Using Shell Commands in JS-Projects or in Scripts in package.json

1. ShellJS

ShellJS is a portable (Windows/Linux/OS X) implementation of Unix shell commands on top of the Node.js API. You can use it to eliminate your shell script’s dependency on Unix while still keeping its familiar and powerful commands. You can also install it globally so you can run it from outside Node projects – say goodbye to those gnarly Bash scripts!

$ npm install [-g] shelljs

2. Shx

shx is a wrapper around ShellJS Unix commands, providing an easy solution for simple Unix-like, cross-platform commands in npm package scripts.

$ npm install shx --save-dev

Difference Between ShellJS and shx

  • ShellJS: Good for writing long scripts, all in JS, running via NodeJS (e.g. node myScript.js).
  • shx: Good for writing one-off commands in npm package scripts (e.g. "clean": "shx rm -rf out/").


Adding SASS Support in Angular Projects

Once the project is generated with Angular/CLI, set default style extension:

ng set defaults.styleExt scss

After you have generated a new component:

ng g c MyComponent

you will see MyComponent.scss in your MyComponent folder.

If you open the scss-file, WebStorm will ask you, if you want to add file-watchers for this type of extension. This procedure is normally not necessary, because angular/cliwill generate and update your project automatically.

Anyway, If you want to add file-watcher for SCSS (on McOS):

  1.  brew install ruby
  2. gem install sass

WebStorm will automatically recognize the installation path (on McOS /usr/local/bin/scss).

Git-TFS-Error: RPC failed; HTTP 501 curl 22 The requested URL returned error: 501 Not Implemented


Counting objects: 131, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (43/43), done.
error: RPC failed; HTTP 501 curl 22 The requested URL returned error: 501 Not Implemented
fatal: The remote end hung up unexpectedly
Writing objects: 100% (131/131), 2.26 MiB | 4.87 MiB/s, done.
Total 131 (delta 102), reused 103 (delta 76)
fatal: The remote end hung up unexpectedly
Everything up-to-date


At first try a garbage collection:

git gc --aggressive

Run this command in root folder of git repository

git config --get http.postBuffer

If it shows nothing, than used default value ( 1 MiB from git config man page )

Now set this value

git config http.postBuffer 524288000

To allow up to the file size 500M

Convert from PFX to CRT/KEY

pkcs12 -in localhost.pfx -clcerts -nokeys -out localhost.crt
pkcs12 -in localhost.pfx -nocerts -nodes -out localhost.key


Angular CLI with SSL

in package.json

"scripts": {
    "https": "ng serve --ssl true --ssl-key \"certs/localhost.key\" --ssl-cert \"certs/localhost.crt\"",

Brew node / npm Problem: Error: Cannot find module ‘semver’

  • sudo rm -rf /usr/local/lib/node_modules
  • sudo rm -rf ~/.npm
  • brew uninstall –force node
  • brew install node

Understanding Scope in TypeScript Array Functions

TypeScript  ↓
let a = {
    foo: 'bar',
    run: function (){

JavaScript  ↓
var a = {
    foo: 'bar',
    run: function () {
        var _this = this;
        setTimeout(function () {
        }, 2000);



A command line utility, a bit like moreutils’s ts, to prepend timestamp information to the standard output of another command. Useful for long-running processes where you’d like a historical record of what’s taking so long.



Observables vs. Functions

Observables are lazy Push collections of multiple values.

Observables are like functions with zero arguments, but generalize those to allow multiple values. Subscribing to an Observable is analogous to calling a Function. Observables are able to deliver values either synchronously or asynchronously.

What is the difference between an Observable and a function? Observables can “return” multiple values over time, something which functions cannot.


  • func.call() means “give me one value synchronously
  • observable.subscribe() means “give me any amount of values, either synchronously or asynchronously

Anatomy of an Observable

Observables are created using Rx.Observable.create or a creation operator, are subscribed to with an Observer, execute to deliver next / error / complete notifications to the Observer, and their execution may be disposed.

Observables can be created with create, but usually we use the so-called creation operators, like of, from, interval, etc.

In an Observable Execution, zero to infinite Next notifications may be delivered. If either an Error or Complete notification is delivered, then nothing else can be delivered afterwards.

When you subscribe, you get back a Subscription, which represents the ongoing execution. Just call unsubscribe() to cancel the execution.


An Observer is a consumer of values delivered by an Observable. Observers are simply a set of callbacks, one for each type of notification delivered by the Observable: next, error, and complete.

The following is an example of a typical Observer object:

var observer = {
  next: x => console.log('Observer got a next value: ' + x),
  error: err => console.error('Observer got an error: ' + err),
  complete: () => console.log('Observer got a complete notification'),

To use the Observer, provide it to the subscribe of an Observable:



A Subscription is an object that represents a disposable resource, usually the execution of an Observable. A Subscription has one important method, unsubscribe, that takes no argument and just disposes the resource held by the subscription. In previous versions of RxJS, Subscription was called “Disposable”.

Subscriptions can also be put together, so that a call to an unsubscribe() of one Subscription may unsubscribe multiple Subscriptions. You can do this by “adding” one subscription into another:

var observable1 = ........
var observable2 = ........

var subscription = observable1.subscribe(...
var childSubscription = observable2.subscribe(...


setTimeout(() => {
  // Unsubscribes BOTH subscription and childSubscription
}, 1000);

Subscriptions also have a remove(otherSubscription) method, in order to undo the addition of a child Subscription.
>> source

RxJS revisited

>> source

Flow Control Operators

filter, delay, debounceTime, take, takeUntil, distinct, distinctUntilChanged, throttleTime


Allow at most one click per second:

var button = document.querySelector('button');
Rx.Observable.fromEvent(button, 'click')
  .scan(count => count + 1, 0)
  .subscribe(count => console.log(`Clicked ${count} times`));

Value Producing Operators

pluck, pairwise, sample,

« Older posts

Copyright © 2020 EBIA

Theme by Anders NorenUp ↑