Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 902B

12345678910111213141516171819
  1. 'use strict';
  2. const path = require('path');
  3. const resolveCwd = require('resolve-cwd');
  4. const pkgDir = require('pkg-dir');
  5. module.exports = filename => {
  6. const globalDir = pkgDir.sync(path.dirname(filename));
  7. const relativePath = path.relative(globalDir, filename);
  8. const pkg = require(path.join(globalDir, 'package.json'));
  9. const localFile = resolveCwd.silent(path.join(pkg.name, relativePath));
  10. const localNodeModules = path.join(process.cwd(), 'node_modules');
  11. const filenameInLocalNodeModules = !path.relative(localNodeModules, filename).startsWith('..');
  12. // Use `path.relative()` to detect local package installation,
  13. // because __filename's case is inconsistent on Windows
  14. // Can use `===` when targeting Node.js 8
  15. // See https://github.com/nodejs/node/issues/6624
  16. return !filenameInLocalNodeModules && localFile && path.relative(localFile, filename) !== '' && require(localFile);
  17. };