How to use the path.delimiter function in path

To help you get started, we’ve selected a few 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 joefitzgerald / go-config / lib / locator.js View on Github external
findToolInDelimitedEnvironmentVariable (toolName, key, options = {}) {
    if (isFalsy(toolName) || toolName.constructor !== String || toolName.trim() === '') {
      return false
    }

    let p = this.environment(options)[key]
    if (isFalsy(p)) {
      return false
    }

    let elements = p.split(path.delimiter)
    if (key === 'GOPATH' && isTruthy(this.environment(options)['GO15VENDOREXPERIMENT'])) {
      // TODO: Understand Vendor Experiment Paths Better
      // elements.unshift('vendor')
    }
    for (let element of elements) {
      let item = ''
      if (key === 'GOPATH') {
        item = path.join(element, 'bin', toolName + this.executableSuffix)
      } else {
        item = path.join(element, toolName + this.executableSuffix)
      }

      if (fs.existsSync(item)) {
        let stat = fs.statSync(item)
        if (stat && stat.isFile() && stat.size > 0) {
          return item
github wintercounter / mhy / src / configs / babel / root / plugins.js View on Github external
const alias = Object.entries(mhyConfig.defaultAliases).reduce(function(acc, [key, entry]) {
            // Leave alone every path which is outside cwd
            const e = path.resolve(entry)
            if (!e.includes(process.cwd())) {
                acc[key] = entry
                return acc
            }

            // Search for last occurrence of src folder and replace it to dist
            if (isBabel) {
                const entrySegments = entry.split(path.delimiter).reverse()
                const srcIndex = entrySegments.findIndex(_ => _ === mhyConfig.srcFolder)
                entrySegments[srcIndex] = mhyConfig.distFolder
                entry = entrySegments.reverse().join(path.delimiter)
            }
            acc[key] = `./${path.relative(process.cwd(), path.resolve(entry))}`
            return acc
        }, {})
        r.push([
github maoberlehner / node-sass-magic-importer / packages / node-sass-selector-importer / js / index.js View on Github external
return function importer(url, prev) {
    // Create an array of include paths to search for files.
    const includePaths = [];
    if (path.isAbsolute(prev)) {
      includePaths.push(path.dirname(prev));
    }
    selectorImporter.options.includePaths = includePaths
      .concat(this.options.includePaths.split(path.delimiter));

    // Merge default with custom options.
    Object.assign(selectorImporter.options, options);
    return selectorImporter.resolveSync(url);
  };
};
github pawelgalazka / tasksfile / src / index.ts View on Github external
const binPath = path.resolve('./node_modules/.bin')

  // Pick relevant option keys and set default values
  const nextOptions = {
    async: !!options.async,
    cwd: options.cwd,
    env: options.env || process.env,
    stdio: options.stdio || 'inherit',
    timeout: options.timeout
  }

  const env = nextOptions.env

  // Include in PATH node_modules bin path
  if (env) {
    env.PATH = [binPath, env.PATH || process.env.PATH].join(path.delimiter)
  }

  logger.log(chalk.bold(command))

  return shell(command, nextOptions)
}
github alexanderGugel / ied / src / run_cmd.js View on Github external
export default function runCmd (cwd, argv) {
	const scripts = argv._.slice(1)

	const pkgJson = readFile(path.join(cwd, 'package.json'), 'utf8')
		::map(JSON.parse)

	// if no script(s) have been specified, log out the available scripts.
	if (!scripts.length) {
		return pkgJson::_do(logAvailable)
	}

	const PATH = [path.join(cwd, 'node_modules/.bin'), process.env.PATH]
		.join(path.delimiter)
	const env = {...process.env, PATH}
	const runOptions = {env, stdio: 'inherit'}

	return pkgJson::map(({scripts = {}}) => scripts)::entries() // eslint-disable-line no-shadow
		::filter(([name]) => ~scripts.indexOf(name))
		::concatMap(([name, script]) => run(script, runOptions)
			::map((code) => ([name, script, code])))
		::_do(logCode)
		::reduce((codes, [name, script, code]) => codes + code, 0)
		::_do((code) => assert.equal(code, 0, 'exit status != 0'))
}
github Topdoc / topdoc / src / default-template / index.js View on Github external
function defaultTemplate(topDocument) {
  try {
    topDocument.files.forEach((file) => {
      file.filename = _replaceExt(file.filename, '.html');
    });
    const content = pug.renderFile(
      path.resolve(__dirname, 'template.pug'),
      { document: topDocument }
    );
    fs.mkdirsSync(path.resolve(topDocument.destination, 'css', path.delimiter));
    const cssDestination = path.resolve(topDocument.destination, 'css', topDocument.filename);
    fs.copySync(topDocument.source, cssDestination);
    const newFileName = topDocument.first ?
      'index.html' : _replaceExt(topDocument.filename, '.html');
    fs.writeFileSync(path.resolve(topDocument.destination, newFileName), content);
    console.log(path.relative(process.cwd(), path.resolve(topDocument.destination, newFileName)));
  } catch (err) {
    console.log(err);
  }
}
github thomasjo / atom-latex / spec / builder-spec.js View on Github external
it('uses platform default when `latex.texPath` is not configured', () => {
      const defaultTexPath = '/foo/bar'
      const expectedPath = [defaultTexPath, process.env.PATH].join(path.delimiter)
      atom.config.set('latex.texPath', '')
      spyOn(builder, 'defaultTexPath').andReturn(defaultTexPath)

      const constructedPath = builder.constructPath()
      expect(constructedPath).toBe(expectedPath)
    })
github joefitzgerald / go-config / spec / pathhelper-spec.js View on Github external
it('expands the path', () => {
      let env = Object.assign({}, process.env)
      env.GOPATH = '~' + path.sep + 'go' + path.delimiter + '~' + path.sep + 'othergo'

      let result = pathhelper.expand(env, path.join('~', 'go', 'go', '..', 'bin', 'goimports'))
      expect(result).toBeDefined()
      expect(result).toBeTruthy()
      expect(result).toBe(path.join(pathhelper.home(), 'go', 'bin', 'goimports'))

      result = pathhelper.expand(env, path.join(gopathToken, 'go', '..', 'bin', 'goimports'))
      expect(result).toBeDefined()
      expect(result).toBeTruthy()
      expect(result).toBe(path.join(pathhelper.home(), 'go', 'bin', 'goimports'))
    })
  })
github tophat / yvm / src / util / path.js View on Github external
export const getPathDelimiter = shell => {
    if (isFishShell(shell)) {
        return ' '
    }
    return path.delimiter
}
github thomasjo / atom-latex / lib / builder.js View on Github external
constructPath () {
    let texPath = (atom.config.get('latex.texPath') || '').trim()
    if (texPath.length === 0) {
      texPath = this.defaultTexPath(process.platform)
    }

    const processPath = process.env[this.envPathKey]
    const match = texPath.match(/^(.*)(\$PATH)(.*)$/)
    if (match) {
      return `${match[1]}${processPath}${match[3]}`
    }

    return [texPath, processPath]
      .filter(str => str && str.length > 0)
      .join(path.delimiter)
  }