Skip to content

Multiple Assets - Not taking objects into account #116

Description

@crash83k

I'm attempting to use multiple static directories. You can use the example shown in the documentation, it will fail.

It attempts to make the DIR but doesn't check if it's an object, instead expects a string.

This will work.
www: path.resolve(__dirname, '..', 'static')

This will not.

www: [
      {
        path: path.resolve(__dirname, '..', 'static'),
        humanUrl: '/admin'
      },
      {
        path: path.resolve(__dirname, '..', 'uploads', 'pictures', 'cats'),
        humanUrl: '/cats'
      }
    ]

This will eventually get to trailpack-core (line 46)

// create paths if they don't exist
    return Promise.all(Object.keys(paths).map(pathName => {
      const dir = paths[pathName]

      try {
        const stats = fs.statSync(dir)

        if (!stats.isDirectory()) {
          this.log.error('The path "', pathName, '" is not a directory.')
          this.log.error('config.main.paths should only contain paths to directories')
          return Promise.reject()
        }
      }
      catch (e) {
        fs.mkdirSync(dir)
      }
    }))
  }

And dir will be the object, not the string. Thus, an error will be thrown killing the server.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions