Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard fork node-parent-require #1239

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/preprocessCss.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const fs = require('fs-extra')
const path = require('path')
const klawSync = require('klaw-sync')
const CleanCSS = require('clean-css')
const prequire = require('parent-require')
const prequire = require('./scripts/parent-require')
const gitignoreScanner = require('./tools/gitignoreScanner')

module.exports = (app, callback) => {
Expand Down
9 changes: 9 additions & 0 deletions lib/scripts/parent-require.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = function (id) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this to lib and credit the original author https://github.com/jaredhanson/node-parent-require

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be specific: credit him in a code comment at the top of the file

let parent = module.parent
for (; parent; parent = parent.parent) {
try {
return parent.require(id)
} catch (ex) {}
}
throw new Error("Cannot find module '" + id + "' from parent")
}
2 changes: 1 addition & 1 deletion lib/setExpressConfigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require('@colors/colors')

const morgan = require('morgan') // express logger
const prequire = require('parent-require')
const prequire = require('./scripts/parent-require')
const express = require('express')
const helmet = require('helmet')

Expand Down
10 changes: 10 additions & 0 deletions lib/support/mk/browserify.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
BROWSERIFY ?= browserify
kethinov marked this conversation as resolved.
Show resolved Hide resolved
BROWSERIFY_MAIN ?= index.js
BROWSERIFY_OUT ?= build/bundle.js

build-browserify: node_modules
mkdir -p build
$(BROWSERIFY) $(BROWSERIFY_MAIN) -o $(BROWSERIFY_OUT)


.PHONY: build-browserify
7 changes: 7 additions & 0 deletions lib/support/mk/coveralls.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
COVERALLS ?= coveralls

submit-istanbul-lcov-to-coveralls:
cat $(ISTANBUL_LCOV_INFO_PATH) | $(COVERALLS)


.PHONY: submit-istanbul-lcov-to-coveralls
20 changes: 20 additions & 0 deletions lib/support/mk/istanbul.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ISTANBUL ?= istanbul
ISTANBUL_OUT ?= ./reports/coverage
ISTANBUL_REPORT ?= lcov
ISTANBUL_HTML_REPORT_PATH ?= $(ISTANBUL_OUT)/lcov-report/index.html
ISTANBUL_LCOV_INFO_PATH ?= $(ISTANBUL_OUT)/lcov.info


test-istanbul-mocha: node_modules
NODE_PATH=$(NODE_PATH_TEST) \
$(ISTANBUL) cover \
--dir $(ISTANBUL_OUT) --report $(ISTANBUL_REPORT) \
$(_MOCHA) -- \
--reporter $(MOCHA_REPORTER) \
--require $(MOCHA_REQUIRE) $(TESTS)

view-istanbul-report:
open $(ISTANBUL_HTML_REPORT_PATH)


.PHONY: test-istanbul-mocha view-istanbul-report
7 changes: 7 additions & 0 deletions lib/support/mk/jshint.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
JSHINT ?= jshint

lint-jshint:
$(JSHINT) $(SOURCES)


.PHONY: lint-jshint
13 changes: 13 additions & 0 deletions lib/support/mk/mocha.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
MOCHA ?= ./node_modules/.bin/mocha
_MOCHA ?= ./node_modules/.bin/_mocha
MOCHA_REPORTER ?= spec
MOCHA_REQUIRE ?= ./test/bootstrap/node

test-mocha: node_modules
NODE_PATH=$(NODE_PATH_TEST) \
$(MOCHA) \
--reporter $(MOCHA_REPORTER) \
--require $(MOCHA_REQUIRE) $(TESTS)


.PHONY: test-mocha
8 changes: 8 additions & 0 deletions lib/support/mk/node.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules:
npm install

clobber-node:
rm -rf node_modules


.PHONY: clobber-node
7 changes: 7 additions & 0 deletions lib/support/mk/notes.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
NOTES ?= 'TODO|FIXME'

notes:
grep -Ern $(NOTES) $(SOURCES) $(TESTS)


.PHONY: notes
7 changes: 7 additions & 0 deletions lib/support/mk/testling.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
TESTLING ?= testling

test-testling: node_modules
$(TESTLING)


.PHONY: test-testling