I am maintaining a global npm package, the package is an CLI
What i want to do is, for example when the user choose 'Iphone 11' option, the next time user run the package again, 'iPhone 11' should be on top, and from that I think I need to save data to do this
Should I doing this by writing using file system module? and where to save that? or is there another way to do this?
there are few way, i would recommend to store the configuration in a file that has a common format (json, yaml, etc.) in appropriate path, such as $HOME/.my-pkg.json, ~/.my-pkg/conf.json, $HOME/.cache/my-pkg/, etc.
I solved this by writing file using fs-extra and save it to __dirname + '/some-file.json'
when I need to read it again, just using require(__dirname + '/some-file.json')