{"id":18561214,"url":"https://github.com/apostrophecms/prettiest","last_synced_at":"2025-12-17T05:56:48.157Z","repository":{"id":24827386,"uuid":"28241959","full_name":"apostrophecms/prettiest","owner":"apostrophecms","description":"Improbably easy data storage and locking for command line scripts. Pairs well with shelljs and a nice chianti.","archived":false,"fork":false,"pushed_at":"2020-01-04T23:21:12.000Z","size":6,"stargazers_count":78,"open_issues_count":0,"forks_count":4,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-10-22T18:48:39.347Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apostrophecms.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-19T18:52:31.000Z","updated_at":"2025-01-03T18:03:44.000Z","dependencies_parsed_at":"2022-07-24T03:30:07.000Z","dependency_job_id":null,"html_url":"https://github.com/apostrophecms/prettiest","commit_stats":null,"previous_names":["punkave/prettiest"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/apostrophecms/prettiest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apostrophecms%2Fprettiest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apostrophecms%2Fprettiest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apostrophecms%2Fprettiest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apostrophecms%2Fprettiest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apostrophecms","download_url":"https://codeload.github.com/apostrophecms/prettiest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apostrophecms%2Fprettiest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27778298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-17T02:00:08.291Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T22:06:13.025Z","updated_at":"2025-12-17T05:56:48.134Z","avatar_url":"https://github.com/apostrophecms.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# prettiest\n\n```javascript\n// The simplest script: keeps track of how many\n// times it has been run. It's like magic!\n\nvar data = require('prettiest')();\n\ndata.count = data.count || 0;\ndata.count++;\nconsole.log('I have been run ' + data.count + ' times.');\n```\n\n`prettiest` provides simple command line apps with two important features:\n\n1. **Persistent data.** Any changes made to the data object returned by `prettiest` are automatically saved when the app exits.\n\n2. **Concurrency locks.** If two copies of your app start at the same time, the second one will always wait for the first one to finish before it proceeds.\n\nIf you're replacing a shell script with something a little smarter, this module is a great companion for [shelljs](http://documentup.com/arturadib/shelljs).\n\n## Install\n\n`npm install prettiest`\n\n## Options\n\nYou can specify where the JSON data file lives:\n\n```javascript\nvar data = require('prettiest')({ json: __dirname + '/mydatafile.json' });\n```\n\nIf you don't, the JSON file lives in the same directory with your app, and will be called `data.json`.\n\n`prettiest` also creates a lock file, which will have the same name as the JSON file, plus `.lock` at the end. To prevent race conditions, the lock file is not removed. Just leave it be.\n\n## Caveats\n\n* The save-and-unlock behavior lives in a `process.on('exit')` handler. Which is great, actually, but just bear in mind it won't fire if node itself crashes. In which case your `data` object probably isn't ready to save anyway, right?\n\n* You don't want to use this in a web application. Duh. It's a simple, synchronous bit of magic for use in utilities with short execution times.\n\n* You don't want to use this in a super-long-running script, because it only saves your data to disk at the very end. It's meant for utilities that do a relatively simple job and then exit.\n\n## Questions\n\n* \"Can my code still be asynchronous?\" Sure, knock yourself out. The save-and-unlock logic runs when your code exits.\n\n## Credits\n\n`prettiest` was built for [ApostropheCMS](https://apostrophecms.com).\n\n## Changelog\n\n1.1.0: dependency on `fs-ext` bumped to 2.0.0, in hopes of smoother cross-platform compilation than with the prereleases. Moved to `const` and `let` since they are supported back to well before currently supported versions of node.\n\n1.0.0: accepted pull request to use newer `fs-ext` because of compilation issues on newer systems. Thanks to Kerrick. Bumped to 1.0.0 stable. Now following semver.\n\n0.1.0: initial release.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapostrophecms%2Fprettiest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapostrophecms%2Fprettiest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapostrophecms%2Fprettiest/lists"}