Skip to content

Docker is not able to include extras with node v4.0.0 #89

@cmtt

Description

@cmtt

With the current stable release of Node.js, docker is not able to bundle extras.

According to Node's path.js and according test/parallel/test-path.js, a TypeError is thrown when calling path.basename() with a non-string second argument.
This behavior is intended by Node's developers, it seems to have been disabled in the iojs period in order to maintain backwards compatibility for a while.

When starting docker with "--extras [extras]" , this error is thrown:

path.js:548
    throw new TypeError('ext must be a string');
    ^

TypeError: ext must be a string
    at posix.basename (path.js:548:11)
    at Array.map (native)
    at Docker.renderCodeHtml (~/docker/src/docker.js:1280:22)
    at ~/docker/src/docker.js:407:18
    at next (~/docker/src/docker.js:1085:37)
    at ~/docker/src/docker.js:1092:7
    at next (~/docker/src/docker.js:1150:39)
    at Docker.highlighExtractedCode (~/docker/src/docker.js:1164:3)
    at Docker.extractDocCode (~/docker/src/docker.js:1128:8)
    at next (~/docker/src/docker.js:1089:10)

Docker is using path.basename as following.

var html = this.renderTemplate({ /* ... */
   js: this.extraJS.map(path.basename),
  css: this.extraCSS.map(path.basename)
});

Therefore, path.basename() is called in the wrong scope (which is being ignored), but Array.prototype.map provides the actual index of the current item as second argument, therefore, a TypeError is thrown.

This affects both POSIX and Win32 environments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions