Skip to content

Instantly share code, notes, and snippets.

View Drecu's full-sized avatar

Michel Drecu

  • Big Dutchman International GmbH
  • Germany
View GitHub Profile
@Drecu
Drecu / update-peer-deps.js
Created November 24, 2021 09:35
Update peer dependency script
/* eslint-disable @typescript-eslint/no-var-requires */
// this script checks the provided peer dependencies (provided as arguments) if they need to be updated, since npm i doesn't up your
// peer dependency versions (this is by design...)
// USAGE: node scripts/update-peer-deps.js peerDep1 peerDep2 andSoOn3
// you might need to update your path to your package.json
const fs = require("fs");
const { execSync } = require("child_process");
const pkgJson = require("../package.json"); // update me if necessary
@Drecu
Drecu / ExpressAndWebsocketOnePort.mjs
Last active March 16, 2022 12:24
WebSocket and Webserver on one Port implementation try
import WebSocket from "ws";
import { createServer } from "http";
import express from "express";
import cors from "cors";
import compression from "compression";
// Description:
// this code demonstrates the use of a HTTP server and WebSocket server on the same Port 8090!
// Testing:
// --------------------------------------------------------------------
@Drecu
Drecu / clean.js
Created February 17, 2021 10:05
Node script to delete folders and files recursively from the cli (usage: node clean.js path1 path2)
/* eslint-disable no-undef */
/* eslint-disable @typescript-eslint/no-var-requires */
var fs = require('fs');
function deleteFolderRecursive(path) {
if(!fs.existsSync(path)) return console.log(`${path} does not exist!`)
if (fs.existsSync(path) && fs.lstatSync(path).isDirectory()) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
fs.readdirSync(path).forEach(function(file, _index){
var curPath = path + "/" + file;