Skip to content

Commit

Permalink
Merge branch 'release/0.2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
DominusKelvin committed Apr 10, 2024
2 parents 4c244af + 8bd0d13 commit a122462
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion create-sails-generator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-sails-generator",
"version": "0.0.1",
"version": "0.0.2",
"description": "Sails generator for The Boring JavaScript Stack.",
"scripts": {
"test": "node --test"
Expand Down
6 changes: 6 additions & 0 deletions create-sails-generator/tests/utils/get-action-name.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ describe('getActionName', function () {
it("returns 'user/view-users' when given 'users/index'", function () {
assert.equal(getActionName('users/index'), 'user/view-users')
})
it("returns 'user/view-user' when given 'users/user'", function () {
assert.equal(getActionName('users/user'), 'user/view-user')
})
it("returns 'user/view-profile' when given 'users/profile'", function () {
assert.equal(getActionName('users/profile'), 'user/view-profile')
})
})
12 changes: 7 additions & 5 deletions create-sails-generator/utils/get-action-name.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module.exports = function getActionName(pageName) {
if (!pageName.includes('/')) return 'view-' + pageName
const [firstPart] = pageName.split('/')
const actionName = 'view-' + firstPart
const singularizedFirsPart = firstPart.replace(/s$/, '')
return `${singularizedFirsPart}/${actionName}`
if (!pageName.includes('/')) return `view-${pageName}`

const [firstPart, secondPart] = pageName.split('/')
const actionName =
secondPart === 'index' ? `view-${firstPart}` : `view-${secondPart}`

return `${firstPart.replace(/s$/, '')}/${actionName}`
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "boring-stack",
"version": "0.2.3",
"version": "0.2.4",
"private": "true",
"description": "The Boring JavaScript Stack 🥱 - an opinionated project starter for fullstack JavaScript",
"scripts": {
Expand Down

0 comments on commit a122462

Please sign in to comment.