[NPMCLI-32] Provide better error handling when files are empty Created: 19/Jul/16  Updated: 14/Feb/17  Resolved: 24/Jan/17

Status: Closed
Project: Magnolia CLI
Component/s: None
Affects Version/s: None
Fix Version/s: 2.0

Type: Improvement Priority: Major
Reporter: Federico Grilli Assignee: Federico Grilli
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Git Code Review
opened during git code review in NPMCLI-23 Referencing with names with dash "-" ... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Epic Link: CLI: Help users get started
Sprint: Basel 80
Story Points: 2

 Description   

To reproduce

  • create a light module called e.g. my-module
  • create an empty page template definition at my-module/templates/pages/super-page.yam (this can easily happen if a dev doesn't use the create-page command)
  • run mgnl add-availability my-module:components/my-comp my-module:pages/super-page@main -p my-module/
    The following error is thrown, which is probably not very useful for an average CLI user
    path.js:7
        throw new TypeError('Path must be a string. Received ' + inspect(path));
        ^
    TypeError: Path must be a string. Received null
        at assertPath (path.js:7:11)
        at Object.join (path.js:1251:7)
        at modifyYamlConfiguration (/Users/fgrilli/devel/workspace/magnolia/build/npm-cli/bin/addAvailability.js:71:35)
        at /Users/fgrilli/devel/workspace/magnolia/build/npm-cli/bin/addAvailability.js:65:5
        at tryToString (fs.js:414:3)
        at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:401:12)
    

Generated at Mon Feb 12 04:45:52 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.