-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix CLI formatting on windows (#119435)
* Provide more guidance on enrollment token * Added suggestions from copy review * Simplify copy * format bash commands correctly * Added suggestions from code review
- Loading branch information
1 parent
94136d6
commit f58cd5c
Showing
5 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/plugins/interactive_setup/public/get_command_line_snippet.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { getCommandLineSnippet } from './get_command_line_snippet'; | ||
|
||
describe('getCommandLineSnippet', () => { | ||
const originalNavigator = window.navigator; | ||
|
||
it('should format windows correctly', () => { | ||
Object.defineProperty(window, 'navigator', { | ||
value: { userAgent: 'Windows' }, | ||
writable: true, | ||
}); | ||
expect(getCommandLineSnippet('kibana')).toEqual('bin\\kibana.bat'); | ||
expect(getCommandLineSnippet('kibana', '--silent')).toEqual('bin\\kibana.bat --silent'); | ||
}); | ||
|
||
it('should format unix correctly', () => { | ||
Object.defineProperty(window, 'navigator', { | ||
value: { userAgent: 'Linux' }, | ||
writable: true, | ||
}); | ||
expect(getCommandLineSnippet('kibana')).toEqual('bin/kibana'); | ||
expect(getCommandLineSnippet('kibana', '--silent')).toEqual('bin/kibana --silent'); | ||
}); | ||
|
||
afterAll(function () { | ||
Object.defineProperty(window, 'navigator', { | ||
value: originalNavigator, | ||
writable: true, | ||
}); | ||
}); | ||
}); |
12 changes: 12 additions & 0 deletions
12
src/plugins/interactive_setup/public/get_command_line_snippet.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export function getCommandLineSnippet(command: string, args?: string) { | ||
const isWindows = window.navigator.userAgent.includes('Win'); | ||
return `${isWindows ? `bin\\${command}.bat` : `bin/${command}`}${args ? ` ${args}` : ''}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters