Zaid-Ajaj / Femto

Femto is a CLI tool that automatically resolves npm packages used by Fable bindings
153 stars 13 forks source link

Femto doesn't work if the project is in a sub folder #48

Closed MangelMaxime closed 5 years ago

MangelMaxime commented 5 years ago

If you try running femto from the root of Fable.React repo it fails to analyze the project.

If I move under src folder then it's working.

Logs:

➜  fable-react git:(master) ✗ femto validate src/Fable.React.fsproj
[09:03:42 INF] Analyzing project src/Fable.React.fsproj
[09:03:43 ERR] Error while analyzing project structure and dependencies
➜  fable-react git:(master) ✗ cd src 
➜  src git:(master) ✗ femto validate Fable.React.fsproj 
[09:05:02 INF] Analyzing project Fable.React.fsproj
[09:05:05 INF] Found package.json in /Users/maximemangel/Workspaces/Github/fable-compiler/fable-react
[09:05:05 INF] Npm packages need to be restored first for project analysis
[09:05:05 INF] Restoring npm packages using 'npm install' inside /Users/maximemangel/Workspaces/Github/fable-compiler/fable-react
[09:05:10 INF] Analyzing project Fable.React.fsproj
[09:05:12 INF] Found package.json in /Users/maximemangel/Workspaces/Github/fable-compiler/fable-react
[09:05:12 INF] Using npm for package management
[09:05:13 INF] Fable.React requires npm package react
[09:05:13 INF]   | -- Required range >= 16.8.0 found in project file
[09:05:13 INF]   | -- Missing react in package.json
[09:05:13 INF]   | -- Resolve manually using 'npm install react@16.8.0 --save'
Zaid-Ajaj commented 5 years ago

I can reproduce the problem but it goes away if you use ./src/{Project} instead of src/{Project} maybe we can detect it and add ./ in the beginning of the path?

MangelMaxime commented 5 years ago

I guess so or perhaps there is a normalize path function in .Net available.

Zaid-Ajaj commented 5 years ago

Yeah there is already one Path.normalizeFullPath but we are using Path.GetFullPath instead, see here

MangelMaxime commented 5 years ago

I didn't touch the helpers Path.normalizeFullPath because it's used for cracking the project and I am not sure if they really wanted to treat them like a real relative path.

So instead, of changing the Path.normalizeFullPath and co which seems to be specific to XML path handling, I used directly the IO.Patch API which treats file path on the system correctly.