How to use expand-tilde - 3 common examples

To help you get started, we’ve selected a few expand-tilde 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 cncjs / cncjs / src / server / index.js View on Github external
url.indexOf(routeWithoutTrailingSlash + '/') < 0) {
                            const redirectUrl = routeWithoutTrailingSlash + '/' + url.slice(routeWithoutTrailingSlash.length);
                            log.debug(`redirect: url=${chalk.yellow(url)}, redirectUrl=${chalk.yellow(redirectUrl)}`);
                            res.redirect(301, redirectUrl);
                            return;
                        }

                        next();
                    });

                    return app;
                }
            });
        } else {
            // expandTilde('~') => '/Users/'
            const directory = expandTilde(ensureString(mount.target)).trim();

            log.info(`Mounting a directory ${chalk.yellow(JSON.stringify(directory))} to serve requests starting with ${chalk.yellow(mount.route)}`);

            if (!directory) {
                log.error(`The directory path ${chalk.yellow(JSON.stringify(directory))} must not be empty.`);
                return;
            }
            if (!path.isAbsolute(directory)) {
                log.error(`The directory path ${chalk.yellow(JSON.stringify(directory))} must be absolute.`);
                return;
            }
            if (!fs.existsSync(directory)) {
                log.error(`The directory path ${chalk.yellow(JSON.stringify(directory))} does not exist.`);
                return;
            }
github zodern / meteor-up / src / utils.js View on Github external
  const expandedPaths = paths.map(_path => expandTilde(_path));
github facebook / flipper / src / chrome / ScreenCaptureButtons.tsx View on Github external
* @format
 */

import {Button, ButtonGroup, writeBufferToFile} from 'flipper';
import React, {Component} from 'react';
import {connect} from 'react-redux';
import expandTilde from 'expand-tilde';
import {remote} from 'electron';
import path from 'path';
import {reportPlatformFailures} from '../utils/metrics';
import config from '../utils/processConfig';
import BaseDevice from '../devices/BaseDevice';
import {State as Store} from '../reducers';
import open from 'open';

const CAPTURE_LOCATION = expandTilde(
  config().screenCapturePath || remote.app.getPath('desktop'),
);

type OwnProps = {};

type StateFromProps = {
  selectedDevice: BaseDevice | null | undefined;
};

type DispatchFromProps = {};

type State = {
  recording: boolean;
  recordingEnabled: boolean;
  capturingScreenshot: boolean;
};

expand-tilde

Bash-like tilde expansion for node.js. Expands a leading tilde in a file path to the user home directory, or `~+` to the cwd.

MIT
Latest version published 8 years ago

Package Health Score

68 / 100
Full package analysis

Popular expand-tilde functions