Giter Site home page Giter Site logo

Comments (4)

tolemac avatar tolemac commented on July 28, 2024

I like this aproach.

This would be a breaking change ... to prevent problems with existing uses of dts-bundle I would keep the behaivor when out parameter don't starts with slash ("/"). But I would change the behaivor when out parameter start with slash.

Then, with out: /dist/si-portal-framework.d.ts the final path must be C:\dev\S-Innovations\S-Innovations.PortalFramework\src\dist\si-portal-framework.d.ts and with out: dist/si-portal-framework.d.ts the final path will continue being C:\dev\S-Innovations\S-Innovations.PortalFramework\src\artifacts\dev\dist\si-portal-framework.d.ts.

If anyone says otherwise, I think it would be good.

from dts-bundle.

tolemac avatar tolemac commented on July 28, 2024

Working on it:

    // Calculate out file path (see #26 https://github.com/TypeStrong/dts-bundle/issues/26)
    function calcOutFilePath(out: any, baseDir: any) {
        var result = path.resolve(baseDir, out);
        // if path is absolute and start with "/" and not is a net route ("//") resolve from local
        if (path.isAbsolute(out) 
            && stringStartsWith(out, path.sep) 
            && !stringStartsWith(out, `${path.sep + path.sep}`)) {

            result = path.resolve(".", out.substr(1));
        }    
        return result;
    }

When the path is absolute and start with slash and not is a net route resolve with the current path.

from dts-bundle.

tolemac avatar tolemac commented on July 28, 2024

Fail to pass tests on travis.

I had tested it on windows where local absolute paths starts with "C:" ... but in linux the absolute paths starts with "/" then no way to determinate if you want absolute path or relative to current path.

I have added the possibility of pass out parameter starting with "~", this way:

    // Calculate out file path (see #26 https://github.com/TypeStrong/dts-bundle/issues/26)
    function calcOutFilePath(out: any, baseDir: any) {
        var result = path.resolve(baseDir, out);
        // if path start with ~, out parameter is relative from current dir
        if (out[0] === "~") {
            result = path.resolve(".", out.substr(1));
        }
        return result;
    }

If test passed I will approve it..

from dts-bundle.

tolemac avatar tolemac commented on July 28, 2024

The out parameter have to start with "~/".

Final code:

// Calculate out file path (see #26 https://github.com/TypeStrong/dts-bundle/issues/26)
    function calcOutFilePath(out: any, baseDir: any) {
        var result = path.resolve(baseDir, out);
        // if path start with ~, out parameter is relative from current dir
        if (stringStartsWith(out, "~" + path.sep)) {
            result = path.resolve(".", out.substr(2));
        }
        return result;
    }

from dts-bundle.

Related Issues (20)

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.