How to use the app-root-path.require function in app-root-path

To help you get started, we’ve selected a few app-root-path examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenZWave / Zwave2Mqtt / lib / Gateway.js View on Github external
/* eslint-disable no-eval */
/* eslint-disable one-var */
'use strict'

const reqlib = require('app-root-path').require
const EventEmitter = require('events')
const comandClass = reqlib('/lib/Constants.js').comandClass
const debug = reqlib('/lib/debug')('Gateway')
const inherits = require('util').inherits
const hassCfg = reqlib('/hass/configurations.js')
const hassDevices = reqlib('/hass/devices.js')
const version = reqlib('package.json').version

debug.color = 2

try {
  const storeDir = reqlib('config/app.js').storeDir
  const customDevices = reqlib(storeDir + '/customDevices')
  let i = 0
  for (const d in customDevices) {
    hassDevices[d] = customDevices[d]
    i++
  }

  debug('Loaded', i, 'custom hass devices configurations')
} catch (error) {
  if (error.message.indexOf('Cannot find module') >= 0) {
github OpenZWave / Zwave2Mqtt / lib / ZwaveClient.js View on Github external
/* eslint-disable camelcase */
'use strict'

// eslint-disable-next-line one-var
var reqlib = require('app-root-path').require,
  OpenZWave = require('openzwave-shared'),
  utils = reqlib('/lib/utils.js'),
  EventEmitter = require('events'),
  fs = require('fs'),
  jsonStore = reqlib('/lib/jsonStore.js'),
  store = reqlib('config/store.js'),
  storeDir = utils.joinPath(true, reqlib('config/app.js').storeDir),
  debug = reqlib('/lib/debug')('Zwave'),
  Tail = require('tail').Tail,
  inherits = require('util').inherits

debug.color = 4

// eslint-disable-next-line no-unused-vars
const nop = () => { }
const ZWAVE_LOG_FILE = utils.joinPath(storeDir, 'OZW_Log.txt')
const readFile = (path) => new Promise((resolve, reject) => fs.readFile(path, 'utf8', (err, data) => err ? reject(err) : resolve(data)))

// https://github.com/OpenZWave/open-zwave/wiki/Adding-Devices#configuration-variable-types
const VAR_TYPES = {
  'bool': (v) => Boolean(v),
  'byte': (v) => parseInt(v),
  'int': (v) => parseInt(v),
  'short': (v) => parseInt(v),
github OpenZWave / Zwave2Mqtt / app.js View on Github external
var express = require('express'),
  reqlib = require('app-root-path').require,
  logger = require('morgan'),
  cookieParser = require('cookie-parser'),
  bodyParser = require('body-parser'),
  app = express(),
  fs = require('fs'),
  SerialPort = require('serialport'),
  jsonStore = reqlib('/lib/jsonStore.js'),
  cors = require('cors'),
  ZWaveClient = reqlib('/lib/ZwaveClient'),
  MqttClient = reqlib('/lib/MqttClient'),
  Gateway = reqlib('/lib/Gateway'),
  store = reqlib('config/store.js'),
  config = reqlib('config/app.js'),
  debug = reqlib('/lib/debug')('App'),
  history = require('connect-history-api-fallback'),
  utils = reqlib('/lib/utils.js');

var gw; //the gateway instance
let io;

debug("Application path:" + utils.getPath(true));

// view engine setup
app.set('views', utils.joinPath(false, 'views'));
app.set('view engine', 'ejs');
github OpenZWave / Zwave2Mqtt / lib / Gateway.js View on Github external
/* eslint-disable no-eval */
/* eslint-disable one-var */
'use strict'

const reqlib = require('app-root-path').require
const EventEmitter = require('events')
const comandClass = reqlib('/lib/Constants.js').comandClass
const debug = reqlib('/lib/debug')('Gateway')
const inherits = require('util').inherits
const hassCfg = reqlib('/hass/configurations.js')
const hassDevices = reqlib('/hass/devices.js')
const version = reqlib('package.json').version

debug.color = 2

try {
  const storeDir = reqlib('config/app.js').storeDir
  const customDevices = reqlib(storeDir + '/customDevices')
  let i = 0
  for (const d in customDevices) {
    hassDevices[d] = customDevices[d]
    i++
  }

  debug('Loaded', i, 'custom hass devices configurations')
} catch (error) {
  if (error.message.indexOf('Cannot find module') >= 0) {
    debug('No custom hass devices file found')
github OpenZWave / Zwave2Mqtt / lib / ZwaveClient.js View on Github external
/* eslint-disable camelcase */
'use strict'

// eslint-disable-next-line one-var
var reqlib = require('app-root-path').require,
  OpenZWave = require('openzwave-shared'),
  utils = reqlib('/lib/utils.js'),
  EventEmitter = require('events'),
  fs = require('fs'),
  jsonStore = reqlib('/lib/jsonStore.js'),
  store = reqlib('config/store.js'),
  storeDir = utils.joinPath(true, reqlib('config/app.js').storeDir),
  debug = reqlib('/lib/debug')('Zwave'),
  Tail = require('tail').Tail,
  inherits = require('util').inherits

debug.color = 4

// eslint-disable-next-line no-unused-vars
const nop = () => { }
const ZWAVE_LOG_FILE = utils.joinPath(storeDir, 'OZW_Log.txt')
const readFile = (path) => new Promise((resolve, reject) => fs.readFile(path, 'utf8', (err, data) => err ? reject(err) : resolve(data)))

// https://github.com/OpenZWave/open-zwave/wiki/Adding-Devices#configuration-variable-types
const VAR_TYPES = {
  'bool': (v) => Boolean(v),
  'byte': (v) => parseInt(v),
github ampleforth / uFragments / test / simulation / supply_precision.js View on Github external
/*
  In this truffle script,
  During every iteration:
  * We double the total fragments supply.
  * We test the following guarantee:
      - the difference in totalSupply() before and after the rebase(+1) should be exactly 1.

  USAGE:
  npx truffle --network ganacheUnitTest exec ./test/simulation/supply_precision.js
*/

const expect = require('chai').expect;
const UFragments = artifacts.require('UFragments.sol');
const _require = require('app-root-path').require;
const BlockchainCaller = _require('/util/blockchain_caller');
const chain = new BlockchainCaller(web3);
const encodeCall = require('zos-lib/lib/helpers/encodeCall').default;
const BigNumber = web3.BigNumber;

const endSupply = new BigNumber(2).pow(128).minus(1);

let uFragments, preRebaseSupply, postRebaseSupply;
preRebaseSupply = new BigNumber(0);
postRebaseSupply = new BigNumber(0);

async function exec () {
  const accounts = await chain.getUserAccounts();
  const deployer = accounts[0];
  uFragments = await UFragments.new();
  await uFragments.sendTransaction({
    data: encodeCall('initialize', ['address'], [deployer]),
github ampleforth / uFragments / migrations / 1_initial_migration.js View on Github external
const Migrations = artifacts.require('./Migrations.sol');
const _require = require('app-root-path').require;
const truffleConfig = _require('/truffle.js');
const accounts = truffleConfig.accounts;

module.exports = function (deployer, network) {
  const deployerAccount = accounts[0];
  const config = truffleConfig.networks[network];
  const deploymentConfig = {
    gas: config.gas,
    from: deployerAccount
  };
  deployer.deploy(Migrations, deploymentConfig);
};
github ampleforth / uFragments / .solcover.js View on Github external
const _require = require('app-root-path').require;
const config = _require('/truffle.js').networks.testrpcCoverage;

module.exports = {
    host: config.host,
    network_id: config.network_id,
    port: config.port,
    gas: config.gas,
    gasPrice: config.gasPrice,
    norpc: true,
    testCommand: 'npx truffle test ./test/unit/*.js',
    compileCommand: 'npx truffle compile',
    skipFiles: ['mocks'],
    copyPackages: ['openzeppelin-eth'],
};
github xing / hops / etc / webpack.watch.js View on Github external
cache: {},
  devtool: '#eval-source-map',
  performance: {
    hints: false
  },
  plugins: [
    new HopsPlugin({
      config: require.resolve('./webpack.node.js'),
      dll: [{
        path: util.format('hops-%s.js', pkg.version),
        source: appRoot.resolve('.tmp/webpack/watch/hops.js')
      }]
    }),
    new webpack.DllReferencePlugin({
      context: appRoot.toString(),
      manifest: appRoot.require('.tmp/webpack/watch/hops.json')
    })
  ]
});
github OpenZWave / Zwave2Mqtt / lib / Gateway.js View on Github external
'use strict'

const reqlib = require('app-root-path').require
const EventEmitter = require('events')
const comandClass = reqlib('/lib/Constants.js').comandClass
const debug = reqlib('/lib/debug')('Gateway')
const inherits = require('util').inherits
const hassCfg = reqlib('/hass/configurations.js')
const hassDevices = reqlib('/hass/devices.js')
const version = reqlib('package.json').version

debug.color = 2

try {
  const storeDir = reqlib('config/app.js').storeDir
  const customDevices = reqlib(storeDir + '/customDevices')
  let i = 0
  for (const d in customDevices) {
    hassDevices[d] = customDevices[d]
    i++
  }

  debug('Loaded', i, 'custom hass devices configurations')
} catch (error) {
  if (error.message.indexOf('Cannot find module') >= 0) {
    debug('No custom hass devices file found')
  } else {
    debug('Error while loading store/customDevices', error.message)
  }
}

const NODE_PREFIX = 'nodeID_'

app-root-path

Determine an app's root path from anywhere inside the app

MIT
Latest version published 2 years ago

Package Health Score

67 / 100
Full package analysis