Skip to content

Instantly share code, notes, and snippets.

View StephaneTrebel's full-sized avatar
🎯
Focusing

Stéphane Trebel StephaneTrebel

🎯
Focusing
View GitHub Profile
@StephaneTrebel
StephaneTrebel / commitmsg.sh
Last active August 11, 2017 07:48
Automagically add the JIRA branch name to the commit message
#!/bin/sh
# Add "commitmsg": "./commitmsg.sh ${GIT_PARAMS}" to your package.json and use Husky to add it as a githook
TICKET=$(git symbolic-ref HEAD | rev | cut -d/ -f1 | rev | grep -o -E "[A-Z]+-[0-9]+")
if [ -n "${TICKET}" ]; then
# sed -e "1s/^/[${TICKET}] /" $1
echo -n "[$TICKET]"' '|cat - "$1" > /tmp/out && mv /tmp/out "$1"
fi
# 1 make your app listen on a port while serving (here we'll use the common 8100 port)
# 2 Run
sudo docker run -it -p 8100:8100 -v /local_project_folder:/docker_project_folder -e ENV_VAR=content -e ANOTHER_ENV_VAR=anothercontenxt image_name
@StephaneTrebel
StephaneTrebel / test.js
Last active February 27, 2020 08:08
Unit testing in nodejs with proxyquire and sinon
// Awesomeness first
const _ = require('lodash');
const proxyquire = require('proxyquire');
const sinon = require('sinon');
// Mocha + Chai are used here but feel free to use your test framework of choice !
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);