Skip to content

Commit 84f0f7e

Browse files
committed
Display first and last path segments in confirmation
1 parent 2fbc81e commit 84f0f7e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

packages/theme/src/cli/utilities/theme-command.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ describe('ThemeCommand', () => {
338338
test('confirmation prompts should display correctly formatted flag values', async () => {
339339
// Given
340340
vi.mocked(loadEnvironment)
341-
.mockResolvedValueOnce({store: 'store1.myshopify.com', password: 'password1', path: 'a/path/to/a-theme'})
342-
.mockResolvedValueOnce({store: 'store2.myshopify.com', password: 'password2', path: 'a/path/to/another-theme'})
341+
.mockResolvedValueOnce({store: 'store1.myshopify.com', password: 'password1', path: '/home/path/to/theme1'})
342+
.mockResolvedValueOnce({store: 'store2.myshopify.com', password: 'password2', path: '/home/path/to/theme2'})
343343

344344
await CommandConfig.load()
345345
const command = new TestThemeCommandWithPathFlag(
@@ -357,8 +357,8 @@ describe('ThemeCommand', () => {
357357
message: ['Run testthemecommandwithpathflag in the following environments?'],
358358
infoTable: {
359359
Environment: [
360-
['development', {subdued: 'store: store1.myshopify.com, password, path: .../a-theme'}],
361-
['staging', {subdued: 'store: store2.myshopify.com, password, path: .../another-theme'}],
360+
['development', {subdued: 'store: store1.myshopify.com, password, path: /home/.../theme1'}],
361+
['staging', {subdued: 'store: store2.myshopify.com, password, path: /home/.../theme2'}],
362362
],
363363
},
364364
confirmationMessage: 'Yes, proceed',

packages/theme/src/cli/utilities/theme-command.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,11 @@ export default abstract class ThemeCommand extends Command {
215215
const usedFlag = Array.isArray(flag) ? flag.find((flag) => flags[flag]) : flag
216216
if (usedFlag === 'password') return `password`
217217
if (usedFlag === 'path' && typeof flags.path === 'string') {
218-
const lastSegment = flags.path.split('/').pop() || flags.path
219-
return `path: .../${lastSegment}`
218+
const splits = flags.path.split(/[/\\]/)
219+
if (splits.length === 1) return `path: ${flags.path}`
220+
const first = splits[0] === '' ? `/${splits[1]}` : splits[0]
221+
const last = splits.at(-1)
222+
return `path: ${first}/.../${last}`
220223
}
221224
return usedFlag && `${usedFlag}: ${flags[usedFlag]}`
222225
})

0 commit comments

Comments
 (0)