mirror of
https://github.com/abrendan/MicDropMessages.git
synced 2025-08-25 05:52:02 +02:00
Initial commit
This commit is contained in:
30
node_modules/app-module-path/.jshintrc
generated
vendored
Normal file
30
node_modules/app-module-path/.jshintrc
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"node" : true,
|
||||
"es5" : false,
|
||||
"browser" : true,
|
||||
"boss" : false,
|
||||
"curly": false,
|
||||
"debug": false,
|
||||
"devel": false,
|
||||
"eqeqeq": true,
|
||||
"evil": true,
|
||||
"forin": false,
|
||||
"immed": true,
|
||||
"laxbreak": false,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": false,
|
||||
"nonew": true,
|
||||
"nomen": false,
|
||||
"onevar": false,
|
||||
"plusplus": false,
|
||||
"regexp": false,
|
||||
"undef": true,
|
||||
"sub": false,
|
||||
"white": false,
|
||||
"eqeqeq": false,
|
||||
"latedef": "func",
|
||||
"unused": "vars",
|
||||
"strict": false,
|
||||
"eqnull": true
|
||||
}
|
9
node_modules/app-module-path/.npmignore
generated
vendored
Normal file
9
node_modules/app-module-path/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/work
|
||||
/build
|
||||
/.idea/
|
||||
/npm-debug.log
|
||||
/node_modules
|
||||
/*.sublime-workspace
|
||||
*.orig
|
||||
.DS_Store
|
||||
coverage
|
133
node_modules/app-module-path/README.md
generated
vendored
Normal file
133
node_modules/app-module-path/README.md
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
[](https://nodei.co/npm/app-module-path/)
|
||||
|
||||
app-module-path
|
||||
=====================
|
||||
|
||||
This simple module enables you to add additional directories to the Node.js module search path (for top-level app modules only). This allows application-level modules to be required as if they were installed into the `node_modules` directory.
|
||||
|
||||
## Installation
|
||||
|
||||
`npm install app-module-path --save`
|
||||
|
||||
## Usage
|
||||
```javascript
|
||||
// ***IMPORTANT**: The following line should be added to the very
|
||||
// beginning of your main script!
|
||||
require('app-module-path').addPath(baseDir);
|
||||
```
|
||||
|
||||
__IMPORTANT:__
|
||||
The search path should be modified before any modules are loaded!
|
||||
|
||||
__Example:__
|
||||
|
||||
In your `my-app/index.js` (or `my-app/server.js`) file:
|
||||
```javascript
|
||||
// Add the root project directory to the app module search path:
|
||||
require('app-module-path').addPath(__dirname);
|
||||
```
|
||||
|
||||
Given the following example directory structure:
|
||||
|
||||
- **my-app/**
|
||||
- **src/** - Source code and application modules directory
|
||||
- **foo/** - A module directory
|
||||
- index.js
|
||||
- **bar/** - Another module directory
|
||||
- index.js
|
||||
- **node_modules/** - Installed modules
|
||||
- **installed-baz/** - An installed module
|
||||
- index.js
|
||||
- index.js - Main script
|
||||
|
||||
The following will work for any modules under the `src` directory:
|
||||
```javascript
|
||||
// All of the following lines will work in "src/foo/index.js" and "src/bar/index.js":
|
||||
var foo = require('src/foo'); // Works
|
||||
var bar = require('src/bar'); // Works
|
||||
var baz = require('installed-baz'); // Works
|
||||
```
|
||||
|
||||
Lastly, by design, installed modules (i.e. modules under the `node_modules` directory) will not be able to require application-level modules so the following will ___not___ work:
|
||||
|
||||
```javascript
|
||||
// All of the following lines will *not* work in "node_modules/installed-baz/index.js"!
|
||||
var foo = require('src/foo'); // Fails
|
||||
var bar = require('src/bar'); // Fails
|
||||
```
|
||||
|
||||
## Alternate Usage (`app-module-path/register`)
|
||||
|
||||
This module supports an alternate method of adding a path to the Node.js module search path that requires less code. Requiring or importing the `app-module-path/register` module will result in the directory of the calling module being added to the Node.js module search path as shown below:
|
||||
|
||||
## Explicitly enabling a directory/package
|
||||
|
||||
By default, `app-module-path` will not attempt to resolve app modules from a directory that is found to be within a `node_modules` directory. This behavior can be changed by explicitly enabling `app-module-path` to work for descendent modules of a specific directory. For example:
|
||||
|
||||
```javascript
|
||||
var packageDir = path.dirname(require.resolve('installed-module-allowed'));
|
||||
require('../').enableForDir(packageDir);
|
||||
```
|
||||
|
||||
|
||||
### ES5
|
||||
|
||||
```javascript
|
||||
require('app-module-path/register');
|
||||
|
||||
// Is equivalent to:
|
||||
require('app-module-path').addPath(__dirname);
|
||||
```
|
||||
|
||||
### ES6
|
||||
|
||||
```javascript
|
||||
import "app-module-path/register";
|
||||
|
||||
// Is equivalent to:
|
||||
import { addPath } from 'app-module-path';
|
||||
addPath(__dirname);
|
||||
```
|
||||
|
||||
## Alternative Usage (`app-module-path/cwd`)
|
||||
|
||||
Additionally, requiring or importing `app-module-path/cwd` will result in the current working directory of the Node.js process being added to the module search path as shown below:
|
||||
|
||||
### ES5
|
||||
|
||||
```javascript
|
||||
require('app-module-path/cwd');
|
||||
|
||||
// Is equivalent to:
|
||||
require('app-module-path').addPath(process.cwd());
|
||||
```
|
||||
|
||||
### ES6
|
||||
|
||||
```javascript
|
||||
import "app-module-path/cwd";
|
||||
|
||||
// Is equivalent to:
|
||||
import { addPath } from 'app-module-path';
|
||||
addPath(process.cwd());
|
||||
```
|
||||
|
||||
## Additional Notes
|
||||
|
||||
* __Search path order:__
|
||||
* App module paths will be added to the end of the default module search path. That is, if a module with the same name exists in both a `node_modules` directory and an application module directory then the module in the `node_modules` directory will be loaded since it is found first.
|
||||
*This behavior is new in v2.x. In v1.x, this search order was reversed*
|
||||
|
||||
* __Node.js compatibility:__
|
||||
* This module depends on overriding/wrapping a built-in Node.js method, and it is possible (but unlikely) that this behavior could be broken in a future release of Node.js (at which point a workaround would need to be used)
|
||||
* This module will _not_ change or break modules installed into the `node_modules` directory.
|
||||
* __Recommendations:__
|
||||
* Since this module changes the Node.js convention of how non-relative modules are resolved, it is recommended (but not required) to put all app modules in a common directory below the application root (such as `my-app/src` or `my-app/app_modules`) and then to add the application root to the search path. The require calls would then be something like `require('src/foo')` or `require('app_modules/foo')`. The common prefix makes it more clear that the module can be found in the application's modules directory and not in the `node_modules` directory.
|
||||
|
||||
|
||||
## Contribute
|
||||
Pull requests, bug reports and feature requests welcome.
|
||||
|
||||
## License
|
||||
|
||||
BSD-2-Clause
|
6
node_modules/app-module-path/cwd.js
generated
vendored
Normal file
6
node_modules/app-module-path/cwd.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
var addPath = require('.').addPath;
|
||||
|
||||
addPath(process.cwd());
|
||||
|
||||
// https://github.com/jhnns/rewire/blob/master/lib/index.js
|
||||
delete require.cache[__filename]; // deleting self from module cache so the parent module is always up to date
|
108
node_modules/app-module-path/lib/index.js
generated
vendored
Normal file
108
node_modules/app-module-path/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
var Module = require('module').Module;
|
||||
var nodePath = require('path');
|
||||
|
||||
var appModulePaths = [];
|
||||
var old_nodeModulePaths = Module._nodeModulePaths;
|
||||
var allowedDirs = {};
|
||||
|
||||
function checkIfDirAllowed(from) {
|
||||
var currentDir = from;
|
||||
|
||||
while (currentDir) {
|
||||
if (allowedDirs[currentDir]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var basename = nodePath.basename(currentDir);
|
||||
if (basename === 'node_modules') {
|
||||
return false;
|
||||
}
|
||||
|
||||
var parentDir = nodePath.dirname(currentDir);
|
||||
if (parentDir === currentDir) {
|
||||
break;
|
||||
}
|
||||
currentDir = parentDir;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Module._nodeModulePaths = function(from) {
|
||||
var paths = old_nodeModulePaths.call(this, from);
|
||||
|
||||
// Only include the app module path for top-level modules
|
||||
// that were not installed or that were explicitly allowed
|
||||
if (checkIfDirAllowed(from)) {
|
||||
paths = paths.concat(appModulePaths);
|
||||
}
|
||||
|
||||
return paths;
|
||||
};
|
||||
|
||||
function enableForDir(dir) {
|
||||
allowedDirs[dir] = true;
|
||||
}
|
||||
|
||||
function addPath(path, parent) {
|
||||
// Anable app-module-path to work under any directories that are explicitly added
|
||||
enableForDir(path);
|
||||
|
||||
function addPathHelper(targetArray) {
|
||||
path = nodePath.normalize(path);
|
||||
if (targetArray && targetArray.indexOf(path) === -1) {
|
||||
targetArray.push(path);
|
||||
}
|
||||
}
|
||||
|
||||
path = nodePath.normalize(path);
|
||||
|
||||
if (appModulePaths.indexOf(path) === -1) {
|
||||
appModulePaths.push(path);
|
||||
// Enable the search path for the current top-level module
|
||||
if (require.main) {
|
||||
addPathHelper(require.main.paths);
|
||||
}
|
||||
|
||||
parent = parent || module.parent;
|
||||
|
||||
// Also modify the paths of the module that was used to load the app-module-paths module
|
||||
// and all of it's parents
|
||||
while(parent && parent !== require.main) {
|
||||
addPathHelper(parent.paths);
|
||||
parent = parent.parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function removePath(path) {
|
||||
function removePathHelper(targetArray) {
|
||||
path = nodePath.normalize(path);
|
||||
if (!targetArray) return;
|
||||
var index = targetArray.indexOf(path);
|
||||
if (index === -1) return;
|
||||
targetArray.splice(index, 1);
|
||||
}
|
||||
|
||||
var parent;
|
||||
path = nodePath.normalize(path);
|
||||
var index = appModulePaths.indexOf(path);
|
||||
|
||||
if (index > -1) {
|
||||
appModulePaths.splice(index, 1);
|
||||
// Enable the search path for the current top-level module
|
||||
if (require.main) removePathHelper(require.main.paths);
|
||||
parent = module.parent;
|
||||
|
||||
// Also modify the paths of the module that was used to load the app-module-paths module
|
||||
// and all of it's parents
|
||||
while(parent && parent !== require.main) {
|
||||
removePathHelper(parent.paths);
|
||||
parent = parent.parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.addPath = addPath;
|
||||
exports.removePath = removePath;
|
||||
exports.enableForDir = enableForDir;
|
62
node_modules/app-module-path/package.json
generated
vendored
Normal file
62
node_modules/app-module-path/package.json
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"_from": "app-module-path@^2.1.0",
|
||||
"_id": "app-module-path@2.2.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-ZBqlXft9am8KgUHEucCqULbCTdU=",
|
||||
"_location": "/app-module-path",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "app-module-path@^2.1.0",
|
||||
"name": "app-module-path",
|
||||
"escapedName": "app-module-path",
|
||||
"rawSpec": "^2.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^2.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/loadware"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/app-module-path/-/app-module-path-2.2.0.tgz",
|
||||
"_shasum": "641aa55dfb7d6a6f0a8141c4b9c0aa50b6c24dd5",
|
||||
"_spec": "app-module-path@^2.1.0",
|
||||
"_where": "/home/runner/Socketio-Chat-Template/node_modules/loadware",
|
||||
"author": {
|
||||
"name": "Patrick Steele-Idem",
|
||||
"email": "pnidem@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/patrick-steele-idem/app-module-path-node/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Simple module to add additional directories to the Node module search for top-level app modules",
|
||||
"devDependencies": {
|
||||
"chai": "^3.5.0",
|
||||
"mocha": "^3.2.0"
|
||||
},
|
||||
"ebay": {},
|
||||
"homepage": "https://github.com/patrick-steele-idem/app-module-path-node",
|
||||
"keywords": [
|
||||
"modules",
|
||||
"path",
|
||||
"node",
|
||||
"extend",
|
||||
"resolve"
|
||||
],
|
||||
"license": "BSD-2-Clause",
|
||||
"main": "lib/index.js",
|
||||
"name": "app-module-path",
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/patrick-steele-idem/app-module-path-node.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/test.js && ./node_modules/mocha/bin/mocha test/test2.js"
|
||||
},
|
||||
"version": "2.2.0"
|
||||
}
|
7
node_modules/app-module-path/register.js
generated
vendored
Normal file
7
node_modules/app-module-path/register.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
var dirname = require('path').dirname;
|
||||
var addPath = require('.').addPath;
|
||||
|
||||
addPath(dirname(module.parent.filename), module.parent);
|
||||
|
||||
// https://github.com/jhnns/rewire/blob/master/lib/index.js
|
||||
delete require.cache[__filename]; // deleting self from module cache so the parent module is always up to date
|
43
node_modules/app-module-path/test/.jshintrc
generated
vendored
Normal file
43
node_modules/app-module-path/test/.jshintrc
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"predef": [
|
||||
"it",
|
||||
"xit",
|
||||
"console",
|
||||
"describe",
|
||||
"xdescribe",
|
||||
"beforeEach",
|
||||
"before",
|
||||
"after",
|
||||
"waits",
|
||||
"waitsFor",
|
||||
"runs"
|
||||
],
|
||||
"node" : true,
|
||||
"es5" : false,
|
||||
"esnext": true,
|
||||
"browser" : true,
|
||||
"boss" : false,
|
||||
"curly": false,
|
||||
"debug": false,
|
||||
"devel": false,
|
||||
"eqeqeq": true,
|
||||
"evil": true,
|
||||
"forin": false,
|
||||
"immed": true,
|
||||
"laxbreak": false,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": false,
|
||||
"nonew": true,
|
||||
"nomen": false,
|
||||
"onevar": false,
|
||||
"plusplus": false,
|
||||
"regexp": false,
|
||||
"undef": true,
|
||||
"sub": false,
|
||||
"white": false,
|
||||
"eqeqeq": false,
|
||||
"latedef": true,
|
||||
"unused": "vars",
|
||||
"eqnull": true
|
||||
}
|
3
node_modules/app-module-path/test/node_modules/installed-module-allowed-explicit/index.js
generated
vendored
Normal file
3
node_modules/app-module-path/test/node_modules/installed-module-allowed-explicit/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
exports.getFoo = function() {
|
||||
return require('installed-module-allowed-explicit-foo');
|
||||
};
|
1
node_modules/app-module-path/test/node_modules/installed-module-allowed-explicit/installed-module-allowed-explicit-foo/index.js
generated
vendored
Normal file
1
node_modules/app-module-path/test/node_modules/installed-module-allowed-explicit/installed-module-allowed-explicit-foo/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
exports.name = 'installed-module-allowed-explicit-foo';
|
5
node_modules/app-module-path/test/node_modules/installed-module-allowed/index.js
generated
vendored
Normal file
5
node_modules/app-module-path/test/node_modules/installed-module-allowed/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
require('../../../register');
|
||||
|
||||
exports.getFoo = function() {
|
||||
return require('installed-module-allowed-foo');
|
||||
};
|
1
node_modules/app-module-path/test/node_modules/installed-module-allowed/installed-module-allowed-foo/index.js
generated
vendored
Normal file
1
node_modules/app-module-path/test/node_modules/installed-module-allowed/installed-module-allowed-foo/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
exports.name = 'installed-module-allowed-foo';
|
16
node_modules/app-module-path/test/node_modules/installed-module/index.js
generated
vendored
Normal file
16
node_modules/app-module-path/test/node_modules/installed-module/index.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
exports.sayHello = function() {
|
||||
console.log('Hello from installed module');
|
||||
|
||||
var moduleA;
|
||||
|
||||
try {
|
||||
moduleA = require('module-a');
|
||||
}
|
||||
catch(e) {
|
||||
console.log('Not able to find module-a from ' + __filename + '... great!');
|
||||
}
|
||||
|
||||
if (moduleA) {
|
||||
throw new Error('module-a should not have been found from ' + __filename + '!');
|
||||
}
|
||||
};
|
5
node_modules/app-module-path/test/src/installed-module.js
generated
vendored
Normal file
5
node_modules/app-module-path/test/src/installed-module.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
exports.sayHello = function() {
|
||||
throw new Error('this should not be required!');
|
||||
};
|
||||
|
||||
exports.isLocal = true;
|
9
node_modules/app-module-path/test/src/module-a/lib/index.js
generated
vendored
Normal file
9
node_modules/app-module-path/test/src/module-a/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
var moduleB = require('module-b');
|
||||
var installedModule = require('installed-module');
|
||||
|
||||
exports.sayHello = function() {
|
||||
console.log('Hello from module-a');
|
||||
moduleB.sayHello();
|
||||
installedModule.sayHello();
|
||||
};
|
3
node_modules/app-module-path/test/src/module-a/package.json
generated
vendored
Normal file
3
node_modules/app-module-path/test/src/module-a/package.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"main": "lib/index"
|
||||
}
|
3
node_modules/app-module-path/test/src/module-b/index.js
generated
vendored
Normal file
3
node_modules/app-module-path/test/src/module-b/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
exports.sayHello = function() {
|
||||
console.log('Hello from module-b');
|
||||
}
|
3
node_modules/app-module-path/test/src/module-c/index.js
generated
vendored
Normal file
3
node_modules/app-module-path/test/src/module-c/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
exports.sayHello = function() {
|
||||
console.log('Hello from module-c');
|
||||
}
|
3
node_modules/app-module-path/test/src/module-d/index.js
generated
vendored
Normal file
3
node_modules/app-module-path/test/src/module-d/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
exports.sayHello = function() {
|
||||
console.log('Hello from module-d');
|
||||
}
|
3
node_modules/app-module-path/test/src/package.json
generated
vendored
Normal file
3
node_modules/app-module-path/test/src/package.json
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "foo"
|
||||
}
|
11
node_modules/app-module-path/test/test-helper-code.js
generated
vendored
Normal file
11
node_modules/app-module-path/test/test-helper-code.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
var path = require('path');
|
||||
|
||||
require('../').addPath(path.join(__dirname, 'src'));
|
||||
|
||||
// other common test setup, e.g.
|
||||
|
||||
// var chai = require("chai");
|
||||
// var dirtyChai = require("dirty-chai");
|
||||
|
||||
// chai.use(dirtyChai);
|
||||
|
13
node_modules/app-module-path/test/test.js
generated
vendored
Normal file
13
node_modules/app-module-path/test/test.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
var path = require('path');
|
||||
var assert = require('assert');
|
||||
require('../').addPath(path.join(__dirname, 'src'));
|
||||
|
||||
require('module-a').sayHello();
|
||||
require('module-b').sayHello();
|
||||
require('installed-module').sayHello();
|
||||
|
||||
assert(require('installed-module.js').isLocal);
|
||||
|
||||
require('package.json');
|
||||
|
||||
console.log('All tests passed!');
|
37
node_modules/app-module-path/test/test2.js
generated
vendored
Normal file
37
node_modules/app-module-path/test/test2.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
var path = require('path');
|
||||
var assert = require('assert');
|
||||
var expect = require('chai').expect;
|
||||
|
||||
require('./test-helper-code.js');
|
||||
|
||||
describe("support for test code", function() {
|
||||
it("should load up a module in a path defined in test helper code", function() {
|
||||
|
||||
require('module-a').sayHello();
|
||||
require('module-b').sayHello();
|
||||
});
|
||||
it("should not search paths that have been removed", function() {
|
||||
require('module-c').sayHello();
|
||||
require('../').removePath(path.join(__dirname, 'src'));
|
||||
assert.throws(function() {
|
||||
require('module-d').sayHello();
|
||||
});
|
||||
});
|
||||
|
||||
it("should allow specific directory to be enabled", function() {
|
||||
var targetDir = path.dirname(require.resolve('installed-module-allowed-explicit'));
|
||||
require('../').addPath(targetDir);
|
||||
require('../').enableForDir(targetDir);
|
||||
|
||||
var foo = require('installed-module-allowed-explicit').getFoo();
|
||||
expect(foo.name).to.equal('installed-module-allowed-explicit-foo');
|
||||
});
|
||||
|
||||
it("should allow directories where loaded", function() {
|
||||
require('../').addPath(path.join(__dirname, 'src'));
|
||||
var foo = require('installed-module-allowed').getFoo();
|
||||
expect(foo.name).to.equal('installed-module-allowed-foo');
|
||||
});
|
||||
});
|
||||
|
||||
console.log('All tests passed!');
|
Reference in New Issue
Block a user