How to use the fs.realpathSync function in fs

To help you get started, we’ve selected a few fs 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 HamidMosalla / FreelancerBlog / WebFor / src / WebFor.Web / node_modules / gulp / node_modules / liftoff / index.js View on Github external
configNameSearch: configNameSearch,
    searchPaths: searchPaths,
    configPath: opts.configPath
  });

  // if we have a config path, save the directory it resides in.
  var configBase;
  if (configPath) {
    configBase = path.dirname(configPath);
    // if cwd wasn't provided explicitly, it should match configBase
    if (!opts.cwd) {
      cwd = configBase;
    }
    // resolve symlink if needed
    if(fs.lstatSync(configPath).isSymbolicLink()) {
      configPath = fs.realpathSync(configPath);
    }
  }

  // TODO: break this out into lib/
  // locate local module and package next to config or explicitly provided cwd
  var modulePath, modulePackage;
  try {
    var delim = (process.platform === 'win32' ? ';' : ':'),
        paths = (process.env.NODE_PATH ? process.env.NODE_PATH.split(delim) : []);
    modulePath = resolve.sync(this.moduleName, {basedir: configBase || cwd, paths: paths});
    modulePackage = silentRequire(fileSearch('package.json', [modulePath]));
  } catch (e) {}

  // if we have a configuration but we failed to find a local module, maybe
  // we are developing against ourselves?
  if (!modulePath && configPath) {
github alibaba / rax / packages / template-retail / webpack.config.js View on Github external
var path = require('path');
var fs = require('fs');
var webpack = require('webpack');
var RaxWebpackPlugin = require('rax-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
var WatchMissingNodeModulesPlugin = require('watch-missing-node-modules-webpack-plugin');
var qrcode = require('qrcode-terminal');
var internalIp = require('internal-ip');
var UglifyJsPlugin = require('uglifyjs-webpack-plugin');

var isProducation = process.env.NODE_ENV === 'production';

// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebookincubator/create-react-app/issues/637
var appDirectory = fs.realpathSync(process.cwd());
function resolveApp(relativePath) {
  return path.resolve(appDirectory, relativePath);
}

var nodePaths = (process.env.NODE_PATH || '')
  .split(process.platform === 'win32' ? ';' : ':')
  .filter(Boolean)
  .map(resolveApp);

var paths = {
  appBuild: resolveApp('build'),
  appPublic: resolveApp('public'),
  appHtml: resolveApp('public/index.html'),
  appIndexJs: resolveApp('templates/default/pages/index/index.js'),
  appPackageJson: resolveApp('package.json'),
  appSrc: resolveApp('src'),
github imodeljs / imodeljs / tools / webpack / config / paths.js View on Github external
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2019 Bentley Systems, Incorporated. All rights reserved.
* Licensed under the MIT License. See LICENSE.md in the project root for license terms.
*--------------------------------------------------------------------------------------------*/
"use strict";

const path = require("path");
const fs = require("fs");

// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebook/create-react-app/issues/637
const appDirectory = fs.realpathSync(process.cwd());
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);

const envPublicUrl = process.env.PUBLIC_URL;
const electronUrlProtocol = (process.env.ELECTRON_ENV === "production") ? "electron://" : null;

function ensureSlash(path, needsSlash) {
  const hasSlash = path.endsWith("/");
  if (hasSlash && !needsSlash) {
    return path.substr(path, path.length - 1);
  } else if (!hasSlash && needsSlash) {
    return `${path}/`;
  } else {
    return path;
  }
}
github philopian / AppSeed / .jest / index.js View on Github external
process.env.BABEL_ENV = "test";
process.env.NODE_ENV = "test";
const fs = require("fs");

const appDirectory = fs.realpathSync(process.cwd());

// Run Jest on the application files (./www/* & ./server/*)
const jest = require("jest");
let jestConfig = require("./config");
jestConfig.roots = [appDirectory];
delete jestConfig.collectCoverageFrom;
delete jestConfig.coverageDirectory;
delete jestConfig.reporters;
const jestCommand = [
  "--env=jsdom",
  "--watchAll",
  "--config",
  JSON.stringify(jestConfig)
];
jest.run(jestCommand);
github chenjun1127 / react-antd-admin / config / paths.js View on Github external
'use strict';

const path = require('path');
const fs = require('fs');
const url = require('url');

// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebook/create-react-app/issues/637
const appDirectory = fs.realpathSync(process.cwd());
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);

const envPublicUrl = process.env.PUBLIC_URL;

function ensureSlash(inputPath, needsSlash) {
  const hasSlash = inputPath.endsWith('/');
  if (hasSlash && !needsSlash) {
    return inputPath.substr(0, inputPath.length - 1);
  } else if (!hasSlash && needsSlash) {
    return `${inputPath}/`;
  } else {
		// return inputPath;
		return `.${inputPath}/`;
  }
}
github npm / tink / lib / node / module.js View on Github external
function toRealPath (requestPath) {
    return fs.realpathSync(requestPath)
  }
github facebookarchive / fb-flo / lib / flo.js View on Github external
function Flo(dir, options, callback) {
  this.log = logger(options.verbose, 'Flo');
  this.dir = dir;
  this.realpathdir = fs.realpathSync(dir);
  this.resolver = callback;
  this.server = new Server({
    port: options.port,
    host: options.host,
    log: logger(options.verbose, 'Server')
  });

  this.watcher = new sane(dir, {
    glob: options.glob,
    poll: options.useFilePolling,
    interval: options.pollingInterval,
    watchman: options.useWatchman,
    dot: options.watchDotFiles
  });
  this.watcher.on('change', this.onFileChange.bind(this));
  this.watcher.on('ready', this.emit.bind(this, 'ready'));
github RanvierMUD / core / src / Data.js View on Github external
static parseFile(filepath) {
    if (!fs.existsSync(filepath)) {
      throw new Error(`File [${filepath}] does not exist!`);
    }

    const contents = fs.readFileSync(fs.realpathSync(filepath)).toString('utf8');
    const parsers = {
      '.yml': yaml.load,
      '.yaml': yaml.load,
      '.json': JSON.parse,
    };

    const ext = path.extname(filepath);
    if (!(ext in parsers)) {
      throw new Error(`File [${filepath}] does not have a valid parser!`);
    }

    return parsers[ext](contents);
  }

fs

This package name is not currently in use, but was formerly occupied by another package. To avoid malicious use, npm is hanging on to the package name, but loosely, and we'll probably give it to you if you want it.

ISC
Latest version published 8 years ago

Package Health Score

67 / 100
Full package analysis