Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

When searching for the root project directory, truffle-config ignores truffle-config.js files. #838

@benjamincburns

Description

@benjamincburns

Issue

When truffle-config is initialized without a working directory specified, it seems that it searches for a truffle project root starting at process.cwd and checking each parent directory until it hits the root directory. If it finds a file called truffle.js in the directory it is searching it uses that as the project root (aka Config.working_directory). This path is then used as the base path for the build, contracts, and test directories.

The problem is that some projects, such as [zeppelin-solidity](https://github.com/openzeppelin/zeppelin-solidity], have opted to use truffle-config.js instead of truffle.js. If you then have a truffle.js file in a directory above your project root, that parent directory is incorrectly used as Config.working_directory, instead.

Steps to Reproduce

  1. cd to the root directory of any truffle project
  2. If your truffle project uses truffle.js as its config, rename this file to truffle-config.js.
  3. Run cp truffle-config.js ../truffle.js to create a truffle.js file one level above your project root.
  4. Run truffle test

Expected Behavior

Tests would run as per usual.

Also in the case when truffle decides not to use process.cwd as the project root, it should print some warning message to indicate that this is the case. Otherwise if nested truffle projects are used, it's possible that truffle commands ran in a child project will actually run against the parent project.

Actual Results

As of truffle v4.1.0:

TypeError: Cannot read property 'filter' of undefined
    at truffle-core/lib/commands/test.js:47:1
    at truffle-core/~/node-dir/lib/paths.js:72:1
    at FSReqWrap.oncomplete (fs.js:166:21)

Environment

  • Operating System: OS X
  • Truffle version (truffle version): v4.1.0 (also tested on v4.0.1)

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