Giter Site home page Giter Site logo

untildify's Introduction

untildify

Convert a tilde path to an absolute path: ~/dev โ†’ /Users/sindresorhus/dev

Install

npm install untildify

Usage

import untildify from 'untildify';

untildify('~/dev');
//=> '/Users/sindresorhus/dev'

Related

See tildify for the inverse.

untildify's People

Contributors

bendingbender avatar linusu avatar raphinesse avatar samverschueren avatar silverwind avatar sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

untildify's Issues

Cannot import without `esModuleInterop` flag set to true

To get this package to work with Typescript, the following must be set to true in the tsconfig.json

{
  "compilerOptions": {
    "esModuleInterop": true
  }
}

Without this, in the latest Typescript (5.1.0), it fails compilation with the message:

error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.

For libraries like https://github.com/aws/jsii they require that esModuleInterop be disabled so this library is unusable in that context.

For example, the following does not work:

import * as untildify from "untildify";

Neither does:

import untildify from "untildify";

Linux - user home instead of the root home

If you use untildify in a Node process started as a root, it expands to /root/. Is there a way to expand to a user's home instead?

One way I can think of is to use process.env.SUDO_USER

Expand ~user syntax

Issuehunt badges

I think this module (and probably the inverse version as well) should supper the ~user syntax whereby ~username/my/path is expanded to /home/username/my/path. It's important to note, though, that the home directory can vary and has to be looked up in the passwd database.

There is a $40.00 open bounty on this issue. Add more on Issuehunt.

Should '~' be resolved?

Right now, only ~/ gets resolved. In my shell, I can do echo ~ and it expands my home folder correctly.

Would you agree to changing this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.