Skip to content

Commit

Permalink
🧹 chore(license): automatically fill in [year] and [fullname] fields
Browse files Browse the repository at this point in the history
Only if they exist.

* `[year]` is changed to the current year.
* `[fullname]` is changed to the user's set Git username.
  • Loading branch information
inttter committed Jun 18, 2024
1 parent ebfd797 commit 2d09f16
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,15 @@ program
});

// fetch the selected license text
const selectedLicenseResponse = await axios.get(`${baseURL}/${selectedLicense}`);
const selectedLicenseText = selectedLicenseResponse.data.body;
let selectedLicenseResponse = await axios.get(`${baseURL}/${selectedLicense}`);
let selectedLicenseText = selectedLicenseResponse.data.body;

// replace [name] and [fullname] fields with git user name and current year
const fullname = gitUserName();
const currentYear = new Date().getFullYear();
selectedLicenseText = selectedLicenseText
.replace('[year]', currentYear)
.replace('[fullname]', fullname);

// write the selected license text to the LICENSE file
const selectedLicenseFilePath = path.join(process.cwd(), 'LICENSE');
Expand Down

0 comments on commit 2d09f16

Please sign in to comment.