ts-morph icon indicating copy to clipboard operation
ts-morph copied to clipboard

addExistingSourceFiles error

Open sajal50 opened this issue 8 years ago • 2 comments

Describe the bug Version: 14.4.1

When adding source files through project.addExistingSourceFiles(["*.ts", "bar/*.ts"]);, I get the following error -

C:\dev\git\scratch\test_ts-simple-ast\node_modules\ts-simple-ast\dist\Project.js:168
            finally { if (e_2) throw e_2.error; }
                               ^

Error: ENOTDIR: not a directory, scandir 'C:\dev\git\scratch\test_ts-simple-ast\bar\chec.ts'
    at Object.fs.readdirSync (fs.js:904:18)
    at DefaultFileSystemHost.readDirSync (C:\dev\git\scratch\test_ts-simple-ast\node_modules\ts-simple-ast\dist\fileSystem\DefaultFileSystemHost.js:35:28)
    at FileSystemWrapper.readDirSync (C:\dev\git\scratch\test_ts-simple-ast\node_modules\ts-simple-ast\dist\fileSystem\FileSystemWrapper.js:740:32)
    at C:\dev\git\scratch\test_ts-simple-ast\node_modules\ts-simple-ast\dist\utils\FileUtils.js:241:57
    at step (C:\dev\git\scratch\test_ts-simple-ast\node_modules\tslib\tslib.js:133:27)
    at Object.next (C:\dev\git\scratch\test_ts-simple-ast\node_modules\tslib\tslib.js:114:57)
    at step (C:\dev\git\scratch\test_ts-simple-ast\node_modules\tslib\tslib.js:118:143)
    at Object.next (C:\dev\git\scratch\test_ts-simple-ast\node_modules\tslib\tslib.js:114:57)
    at Function.from (native)
    at Function.FileUtils.getDescendantDirectories (C:\dev\git\scratch\test_ts-simple-ast\node_modules\ts-simple-ast\dist\utils\FileUtils.js:235:22)

It works fine when I do project.addExistingSourceFiles(["foo/*.ts", "bar/*.ts"]);, or just project.addExistingSourceFiles(["*.ts"]);

To Reproduce

Set up a dir structure as

foobar.ts
foo/
      bar.ts
bar/
     foo.ts

And then run project.addExistingSourceFiles(["*.ts", "bar/*.ts"]);,

Expected behavior

Should be able to add the specified files in the specified glob pattern.

sajal50 avatar Aug 27 '18 21:08 sajal50

Thanks for reporting @sajal50! I had internally named a method incorrectly then used it according to its incorrect name (classic). Fixed and released in 14.4.2.

dsherret avatar Aug 27 '18 23:08 dsherret

Thank you, @dsherret, for the quick resolution!

sajal50 avatar Aug 28 '18 13:08 sajal50