Tsoa: Routes command fails if directory isn't found

Created on 6 Jul 2020  路  6Comments  路  Source: lukeautry/tsoa

Sorting

  • I'm submitting a ...

    • [x] bug report
    • [ ] feature request
    • [ ] support request
  • I confirm that I

    • [x] used the search to make sure that a similar issue hasn't already been submit

Expected Behavior

Running tsoa routes does not throw errors if the target directory doesn't exist.

Current Behavior

$ tsoa routes

Generate routes error.
 Error: ENOENT: no such file or directory, lstat 'tsoa-package'
    at Object.lstatSync (fs.js:924:3)
    at RouteGenerator.<anonymous> ([...]/node_modules/tsoa/dist/routeGeneration/routeGenerator.js:81:33)

Running tsoa spec-and-routes if the spec outputDirectory is the same as the routesDir doesn't have this issue - it creates the folder if not present already.

Possible Solution

I'm guessing the spec part is creating a folder but not the routes - just copy that behaviour across to the routes command.

Steps to Reproduce


tsoa.config

{
  "spec": {
    "outputDirectory": "tsoa-spec",
    "specVersion": 3
  },
  "routes": {
    "routesDir": "tsoa-routes"
  }
}
  1. $ rm -rf tsoa-routes && tsoa routes or $ rm -rf tsoa-routes && tsoa spec-and-routes

Context (Environment)

Version of the library: 3.2.1
Version of NodeJS: 12.16.2

  • [ ] Confirm you were using yarn not npm

I'm using npm.

bug good first issue help wanted

Most helpful comment

The tradition, to keep a directory around in git is to add an empty .gitkeep file inside the folder.

This is purely a convention, and really it could just be any file.

see https://stackoverflow.com/a/7229996/474763

All 6 comments

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

This issue isn't stale

This issue also happens occasionally if the folder is the same for routes and spec. This is due to a race condition as spec and route generation run concurrently: https://github.com/lukeautry/tsoa/blob/1b74e4545096dce76df9a1dcefa68b334fe4f6e5/packages/cli/src/cli.ts#L357

Any updates on this? We are not committing the routes.ts file due to conflicts on each PR and wanting to build the latest routes during deployment phase.
It fails in github since an empty directory can't be committed.
If you also don't commit your routes.ts file a work around for us is to add any file to the routes/ directory.

The tradition, to keep a directory around in git is to add an empty .gitkeep file inside the folder.

This is purely a convention, and really it could just be any file.

see https://stackoverflow.com/a/7229996/474763

@tsimbalar Thanks this is exactly what I was looking for.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cedricboidin picture cedricboidin  路  5Comments

lonix1 picture lonix1  路  5Comments

strongpauly picture strongpauly  路  3Comments

williamdes picture williamdes  路  5Comments

sundowndev picture sundowndev  路  4Comments