question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to create a dir with `fromJSON` without using a temp file?

See original GitHub issue

mock-fs supports a nested structure and represents empty dirs as empty objects.

At present I am using the flat module to take a nested structure into fromJSON, but there seems no way to create dirs without dummy files.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
G-Rathcommented, Oct 17, 2020

@alex996 while it does technically work at runtime, I think the types should remain as requiring null because using {} naturally leads to assuming { '/some-dir': { '/some-nested-dir': {} } } would work, which it doesn’t (for that you need to call fromNestedJSON), and because {} in TS actually means an open object, so it makes it a bit of a footgun & technically a breaking change if we wanted to say merge fromJSON & fromNestedJSON.

1reaction
streamichcommented, May 3, 2018

Can be done now using {} object literal:

Read more comments on GitHub >

github_iconTop Results From Across the Web

Generate temporary file names without creating actual file in ...
better way to create a temp directory is temp_dir = tempfile.mkdtemp(prefix='some-prefix_') which will safely create a temporary directory and return a string ...
Read more >
Spark Read and Write JSON file into DataFrame
Spark SQL also provides a way to read a JSON file by creating a temporary view directly from reading file using spark.
Read more >
Read/Write JSON Files with Node.js | heynode.com
Learn to use fs module to interact with the filesystem; Persist data to a JSON file; Use JSON.parse and JSON.stringify to convert data...
Read more >
JSON Files - Spark 3.3.1 Documentation
Property Name Default Scope primitivesAsString false read prefersDecimal false read allowComments false read
Read more >
Display Records or Data From JSON File in React - YouTube
Use map to display records from JSON file in ReactJS. You can use data in object form in a JSON file and then...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found