Skip to content

Instantly share code, notes, and snippets.

View lennym's full-sized avatar

Leonard Martin lennym

View GitHub Profile
11:22 AM <lennym> Morning all, I'm having some issues with node-sass and npm, but only in certain contexts. I was hoping to talk it through to see if I'm doing anything obviously stupid.
11:23 AM <lennym> I have a project, which has a module as a dev dependency - both depend on node sass, and both run node sass as part of a postinstall script
11:24 AM <lennym> Except the postinstall script fails in node-sass for the child module with an error of "Cannot find module semver" here - https://github.com/sass/node-sass/blob/v2.1.1/lib/extensions.js#L1
11:24 AM <lennym> When run not as a child dependency of the parent project it works fine.
11:24 AM <lennym> Both projects have the same (2.1.1) dependency of node-sass
11:25 AM <lennym> Now here's the kicker... it *only* fails as part of an npm install on our jenkins build server, I can't replicate locally.
11:26 AM <lennym> If anyone has any ideas or suggestions I'd be happy to hear them.
function requestHandler(req, res) {
fs.readFile('/my/file', function (err, file) {
if (err) {
res.status(500).send();
} else {
res.send(file);
}
});
}
@lennym
lennym / mocha.js
Created July 1, 2015 12:04
mocha async setup example
var getApp = require('./main');
describe('App Tests', function () {
var app;
beforeEach(function (done) {
getApp(function (err, a) {
app = a;
done(err);
var app = require('express')();
app.get('/foo', function (req, res, next) {
res.send(req.path);
// here req.path === '/foo'
});
app.use('/bar', function (req, res, next) {
res.send(req.path);
// here req.path === '/'
const a = {};
a.foo = 'bar';
console.log(a); // { foo: 'bar' }
const b = 'foo';
b += 'bar';
console.log(b); // 'foo'
const AWS = require('aws-sdk');
const assert = require('assert');
const kinesis = new AWS.Kinesis({ region: 'eu-west-1' });
function start () {
kinesis.describeStream({ StreamName: 'isearch' }, (err, result) => {
assert(!err);
console.log(result);
setInterval(write, 1000);
@lennym
lennym / s3.touch.js
Last active December 2, 2018 22:14
'use strict';
require('env2')('.env');
const AWS = require('aws-sdk');
const async = require('async');
const Progress = require('cli-progress');
AWS.config.region = 'eu-west-1';
const s3 = new AWS.S3();
@lennym
lennym / app.js
Created July 19, 2016 14:55
Express middleware mounting patterns
const app = require('express');
app.use(require('./default-middleware'));
app.use(require('./router'));
module.exports = app;
const simple = require('simple-mock');
const AWS = require('aws-sdk');
const S3 = (new AWS.S3()).constructor.prototype;
describe('store', () => {
beforeEach(() => {
simple.mock(S3, 'getObject').callbackWith(null, mockResult);
});
afterEach(() => {
simple.restore();
const assert = require('assert');
const sandbox = require('./sandbox');
function myAsyncFn (callback) {
setTimeout(() => {
callback(null, 5);
}, 500);
}
describe('async things', () => {