{"id":16760397,"url":"https://github.com/ryanve/yearly","last_synced_at":"2025-03-16T09:16:43.358Z","repository":{"id":57403478,"uuid":"115962498","full_name":"ryanve/yearly","owner":"ryanve","description":"Year utility to test or bump year in a string. Useful for keeping license files current.","archived":false,"fork":false,"pushed_at":"2018-01-07T06:02:01.000Z","size":17,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T21:51:24.110Z","etag":null,"topics":["javascript","opensource"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/yearly","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryanve.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-02T01:42:42.000Z","updated_at":"2023-11-07T15:29:06.000Z","dependencies_parsed_at":"2022-09-15T04:42:27.367Z","dependency_job_id":null,"html_url":"https://github.com/ryanve/yearly","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fyearly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fyearly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fyearly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fyearly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanve","download_url":"https://codeload.github.com/ryanve/yearly/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243847056,"owners_count":20357317,"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","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":["javascript","opensource"],"created_at":"2024-10-13T04:23:23.044Z","updated_at":"2025-03-16T09:16:43.321Z","avatar_url":"https://github.com/ryanve.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `yearly`\n\nYear utility to test or bump year in a string. Useful for keeping license files up to date.\n\n```\nnpm install yearly\n```\n\n```js\nconst yearly = require(\"yearly\")\n```\n\n## API\n\n### `yearly.bump(content)`\nReplace any years in `content` with the current year. Uses `yearly.express` and `yearly.full`\n\n```js\nyearly.bump(\"47\") // \"2018\"\nyearly.bump(\"1999 4ever\") // \"2018 4ever\"\nyearly.bump(\"2000 8000\") // \"2018 2018\"\nyearly.bump(\"Copyright (c) 1999 Mickey Mouse\") // \"Copyright (c) 2018 Mickey Mouse\"\n```\n\n### `yearly.test(content)`\nTest if `content` contains current year. Uses `yearly.express` and `yearly.full`\n\n```js\nyearly.test(\"2018 4ever\") // true\nyearly.test(\"02018\") // false\n```\n\n### `yearly.express(year)`\nCreate regex for `year` string. Uses word boundary in expression\n\n```js\nyearly.express(\"1999\") // /\\b1999\\b/g\n```\n\n### `yearly.full()`\nGet the full current local year string\n\n```js\nyearly.full() // \"2018\"\n```\n\n## `node`\n\n### `test` if license has current year\n\n```\nnpm install yearly --save-dev\n```\n\n```js\nconst yearly = require(\"yearly\")\nconst assert = require(\"assert\")\nconst fs = require(\"fs\")\n\nassert.ok(\n  yearly.test(fs.readFileSync(\"LICENSE\")),\n  \"Please update LICENSE to current year: \" + yearly.full()\n)\n```\n\n### `bump` license file\n\n```\nnpm install edit-file yearly --save-dev\n```\n\n```js\nconst editFile = require(\"edit-file\")\nconst yearly = require(\"yearly\")\n\neditFile(\"LICENSE\", yearly.bump)\n```\n\n```\ngit diff\n```\n\n### hook into [`npm version`](https://docs.npmjs.com/cli/version) commit\n\n```\nnpm install edit-file said yearly --save-dev\n```\n\nCreate a `yearly.js` file in your package\n\n```js\nconst yearly = require(\"yearly\")\nconst editFile = require(\"edit-file\")\nconst said = require(\"said\")\n\neditFile(\"LICENSE\", yearly.bump, err =\u003e {\n  if (err) throw err\n  if (said(\"git diff LICENSE\")) {\n    said(\"git add LICENSE\")\n    console.log(\"Updated: LICENSE\")\n  }\n})\n```\n\nUse [`version`](https://docs.npmjs.com/misc/scripts) script in your `package.json`\n\n```json\n\"scripts\": {\n  \"version\": \"node yearly\"\n}\n```\n\n## `npm test` logs bump examples\n\n```\nnode test\nTesting...\n\n0 =\u003e 2018\n2000 =\u003e 2018\n-0 =\u003e -2018\n0- =\u003e 2018-\n4747474747 =\u003e 2018\n02018 =\u003e 2018\n20182018 =\u003e 2018\n2000 8000 =\u003e 2018 2018\n2000.8000 =\u003e 2018.2018\n2000,8000 =\u003e 2018,2018\n2000-8000 =\u003e 2018-2018\nB2B =\u003e B2B\n9999 4EVER =\u003e 2018 4EVER\n2000_8000 =\u003e 2000_8000\n2000x8000 =\u003e 2000x8000\nCopyright (c) 1999 Mickey Mouse =\u003e Copyright (c) 2018 Mickey Mouse\nCopyright (c) 1999 Mickey Mouse =\u003e Copyright (c) 2018 Mickey Mouse\nCopyright (c) 1999, Mickey Mouse =\u003e Copyright (c) 2018, Mickey Mouse\n\nTests passed :)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanve%2Fyearly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanve%2Fyearly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanve%2Fyearly/lists"}