How to use the app-root-path.toString 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 giltig / rxfrf / tools / webpack / configFactory.js View on Github external
const path = require('path')
const webpack = require('webpack')
const AssetsPlugin = require('assets-webpack-plugin')
const nodeExternals = require('webpack-node-externals')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const dotenv = require('dotenv')
const appRoot = require('app-root-path')
const WebpackMd5Hash = require('webpack-md5-hash')
const { removeEmpty, ifElse, merge } = require('../utils')

const appRootPath = appRoot.toString()

// @see https://github.com/motdotla/dotenv
dotenv.config(process.env.NOW
  // This is to support deployment to the "now" host.  See the README for more info.
  ? { path: '../../.envnow', silent: true }
  // Standard .env loading.
  : { silent: true }
)

function webpackConfigFactory ({ target, mode }, { json }) {
  if (!target || !~['client', 'server'].findIndex(valid => target === valid)) {
    throw new Error(
      'You must provide a "target" (client|server) to the webpackConfigFactory.'
    )
  }
github kopz9999 / ng-node-environment / index.js View on Github external
var commandLineArgs = require('command-line-args');
var camelize = require('camelize');
var fs = require('fs');
var path = require('path');
var appRoot = require('app-root-path');
var currentValue, environmentProperty, environmentBase, tsString, booleanValue;

var optionDefinitions = [
  { name: 'out', alias: 'o', type: String },
  { name: 'in', alias: 'i', type: String },
];

var options = commandLineArgs(optionDefinitions);
var environmentPath = options['in'] || path.join(appRoot.toString(), 'environment.json');;
var tsEnvironmentPath = options['out'] || path.join(appRoot.toString(), 'src', 'environments', 'base.ts')

if (fs.existsSync(environmentPath)) {
  console.log('Reading base environment: ' + environmentPath);
  environmentBase = JSON.parse(fs.readFileSync(environmentPath, 'utf-8').toString());
} else {
  environmentBase = {};
}

require('dotenv').config();

Object.keys(process.env).forEach(function (key) {
  if (key.startsWith('NG_')) {
    currentValue = process.env[key];
    booleanValue = currentValue.toLowerCase();
    environmentProperty = camelize(key.substr(3).toLowerCase());
    if (booleanValue === 'true' || booleanValue === 'false') {
github stricter / stricter / src / config / read-config.ts View on Github external
export default (configPath?: string): ConfigFile => {
    if (configPath) {
        return {
            filePath: configPath,
            config: require(configPath),
        };
    }

    const rootDir = appRoot.toString();
    const defaultConfigPath = path.join(rootDir, 'stricter.config.js');

    return {
        filePath: defaultConfigPath,
        config: require(defaultConfigPath),
    };
};
github microsoft / WebTemplateStudio / src / extension / src / azure / azure-functions / utils / fileHelper.ts View on Github external
function createFolderForNode(dirPath: string): void {
    createFolder(dirPath);

    let indexPath: string = path.join(
      appRoot.toString(),
      FUNCTION_TEMPLATES_RELATIVE_PATH,
      BASE_NODE_FUNCTION_PATH
    );
    let funcJsonPath: string = path.join(
      appRoot.toString(),
      FUNCTION_TEMPLATES_RELATIVE_PATH,
      BASE_NODE_FUNCTION_CONFIG_PATH
    );

    fs.copyFileSync(indexPath, path.join(dirPath, "index.js"));
    fs.copyFileSync(funcJsonPath, path.join(dirPath, "function.json"));
  }
github microsoft / WebTemplateStudio / src / extension / src / azure / azure-functions / functionProvider.ts View on Github external
private getFunctionsARMParameters(selections: FunctionSelections): any {
    let parametersPath = path.join(
      appRoot.toString(),
      "src",
      "azure",
      "azure-functions",
      "arm-templates",
      "parameters.json"
    );

    let parameters = JSON.parse(fs.readFileSync(parametersPath, "utf8"));

    parameters.parameters = {
      name: {
        value: selections.functionAppName
      },
      location: {
        value: selections.location
      },
github NativeScript / nativescript-dev-appium / utils.js View on Github external
function projectDir() {
    return require('app-root-path').toString();
}
exports.projectDir = projectDir;
github xing / hops / lib / config.js View on Github external
return fallback ? path.resolve(__dirname, fallback) : null;
  }
}

function getSourceDir() {
  try { return path.dirname(require.resolve(appRoot)); }
  catch (e) { return appRoot.resolve('src'); }
}

function overrideConfig(config) {
  try { return Object.assign(config, appRoot.require('.hopsrc')); }
  catch (e) { return config; }
}

module.exports = overrideConfig({
  appRoot: appRoot.toString(),
  distDir: appRoot.resolve('dist'),
  eslint: getFilePath('.eslintrc.js', '../etc/eslint.js'),
  srcDir: getSourceDir(),
  stylelint: getFilePath('.stylelintrc.js', '../etc/stylelint.js'),
  testGlob: appRoot.resolve('!(node_modules)/**/*.test.js'),
  webpack: getFilePath('webpack.js', '../etc/webpack.js'),
  webpackBase: getFilePath('webpack.base.js', '../etc/webpack.base.js'),
  webpackDev: getFilePath('webpack.dev.js', '../etc/webpack.dev.js'),
  webpackBuild: getFilePath('webpack.build.js', '../etc/webpack.build.js')
});
github atomist / sdm-pack-aspect / lib / analysis / offline / persist / FileSystemProjectAnalysisResultStore.ts View on Github external
constructor(userPath?: string) {
        if (!!userPath) {
            this.path = userPath;
        } else {
            const defaultPath = path.join(appRoot.toString(), "spidered");
            this.path = defaultPath;
        }
        if (!fs.existsSync(this.path)) {
            logger.info("Creating directory '%s' to store analyses...", path);
            fs.mkdirSync(this.path);
        }
    }
github microsoft / WebTemplateStudio / src / extension / src / azure / azure-functions / functionProvider.ts View on Github external
private getFunctionsARMTemplate(): any {
    let templatePath = path.join(
      appRoot.toString(),
      "src",
      "azure",
      "azure-functions",
      "arm-templates",
      "template.json"
    );

    return JSON.parse(fs.readFileSync(templatePath, "utf8"));
  }

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