Skip to content

Instantly share code, notes, and snippets.

View mfncooper's full-sized avatar

Martin Cooper mfncooper

View GitHub Profile
@mfncooper
mfncooper / npm_3121_test.js
Created February 4, 2013 02:13
Illustrates "Bug in specialising config for publishing", https://github.com/isaacs/npm/issues/3121 Creating an npmconf.Conf instance from an existing instance results in the correct lookup chain, but loses named configs.
// Illustrates "Bug in specialising config for publishing"
// https://github.com/isaacs/npm/issues/3121
var npmconf = require('npmconf');
npmconf.load({ abc: 'my_cli_value'}, function (err, conf) {
// Print some entries from the initial config
console.log("Original config:");
console.log("\tabc: ", conf.get('abc', 'cli'));
console.log("\ttag: ", conf.get('tag'));
@mfncooper
mfncooper / test_cache_bypass.js
Created December 28, 2012 18:52
When a module is 'require'd before mockery is enabled, mockery will still provide the mock when enabled, bypassing the cache entry.
var mockery = require('../mockery'),
fake_module;
var mock_fake_module = {
foo: function () {
return 'mocked foo';
}
};
fake_module = require('./fixtures/fake_module');
@mfncooper
mfncooper / zread.js
Created September 29, 2012 16:08
Reading a zip file header with reify
var fs = require('fs');
var path = require('path');
var exists = fs.existsSync || path.existsSync;
var reified = require('reified'),
StructT = reified.StructType,
NumT = reified.NumericType,
Uint16 = NumT.Uint16,
Uint32 = NumT.Uint32;