Skip to content

Instantly share code, notes, and snippets.

View mantoni's full-sized avatar
💭
Amending fixup commits

Maximilian Antoni mantoni

💭
Amending fixup commits
View GitHub Profile
'use strict';
const fs = require('fs');
module.exports = {
'*.js': [
'eslint --fix',
(files) => {
const tests = findTests(files);
return tests.length ? `npm run test:files -- ${tests.join(' ')}` : 'echo';
@mantoni
mantoni / index.js
Created February 28, 2018 20:14
SInon yields demo
'use strict';
const fs = require('fs');
exports.readJsonFile = function (file, callback) {
fs.readFile(file, 'utf8', (err, content) => {
if (err) {
callback(err);
return;
}
@mantoni
mantoni / index.js
Last active August 29, 2015 14:18
Mocha diff shown for thrown Error
describe('diff', function () {
it('is shown with no diff', function () {
var e = new Error();
e.showDiff = true; // because the showDiff fix is not in a release yet
throw e;
});
});
@mantoni
mantoni / index.js
Created March 21, 2015 20:28
Mocha diff not working with assert
/*global describe, it*/
'use strict';
var assert = require('assert');
describe('diff', function () {
it('works', function () {
assert.equal('foo', 'bar');
});
@mantoni
mantoni / unused-var.js
Created March 21, 2015 16:32
JSLint unused variable
/*jslint node: true */
'use strict';
var x = require('x');
function foo() {
var y = 'bar';
}
// JSLint reports "Unused 'y'.", but not Unused 'x'.
@mantoni
mantoni / chrome.md
Last active June 30, 2021 18:55
Increase stack trace limit in Google Chrome

Command line args:

--js-flags="--stack-trace-limit 20"
@mantoni
mantoni / error.js
Created September 2, 2013 15:27
Error.getStackTrace() for IE
(function () {
"use strict";
var callee = "callee"; // Trick JSLint. It hates arguments.callee.
var isStrict = false;
try {
if (!arguments[callee]) {
throw new Error();
}
} catch (e) {
@mantoni
mantoni / test.sh
Last active February 9, 2024 15:00
Minimal bash unit testing framework
#!/bin/bash
#
# Copyright (c) 2013 Maximilian Antoni
#
export TEST_COLOR_GREEN="\033[1m\033[32m"
export TEST_COLOR_RED="\033[1m\033[31m"
export TEST_COLOR_TITLE="\033[1m\033[36m"
export TEST_COLOR_OFF="\033[0m"
export TEST_SPACES=" "
export TEST_LINE="-----------------------------------------------------"