Skip to content

Commit

Permalink
chore(snippets): improved documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
YuryShkoda committed Jul 19, 2023
1 parent 3104383 commit ab8378e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions src/commands/help/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,11 @@ export async function printHelpText() {
name: 'snippets',
title: 'snippets',
description: [
`Generates snippets from macros.`,
`Generates VS Code snippets from macros.`,
`[2spaces]command example: sasjs snippets --outDirectory <folderPath> --target <targetName>`,
``,
`[2spaces]NOTE: Providing <folderPath> is optional. If not present, generated snippets will be saved to 'sasjs-macro-snippets.json' file.`
`[2spaces]NOTE: Providing <folderPath> is optional. If not present, generated snippets will be saved to 'sasjsresults/sasjs-macro-snippets.json' file.`,
`[2spaces]NOTE: more information can be found here https://cli.sasjs.io/snippets/.`
]
}
]
Expand Down
5 changes: 2 additions & 3 deletions src/commands/snippets/snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export async function generateSnippets(
config?: Configuration,
outDirectory?: string
) {
console.log(`🤖[outDirectory]🤖`, outDirectory)
let macroFolders: string[] = []

const configMacroFolders = config?.macroFolders
Expand All @@ -43,7 +42,7 @@ export async function generateSnippets(

if (!macroFolders.length) {
return Promise.reject(
`"macroFolders" array was not found in sasjsconfig.json.`
`"macroFolders" array was not found in sasjs/sasjsconfig.json.`
)
}

Expand All @@ -64,7 +63,7 @@ export async function generateSnippets(
})

if (!Object.keys(snippets).length) {
return Promise.reject('No snippets has been found.')
return Promise.reject('No VS Code snippets has been found.')
}

const defaultOutputFileName = 'sasjs-macro-snippets.json'
Expand Down
5 changes: 4 additions & 1 deletion src/commands/snippets/snippetsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const parseOptions = {
type: 'string',
alias: 'o',
description:
'Path to the directory where the snippets output will be generated.'
'Path to the directory where the VS Code snippets output will be generated.'
}
}

Expand All @@ -36,6 +36,9 @@ export class SnippetsCommand extends TargetCommand {
process.logger?.success(
`VS Code snippets generated! File location: ${filePath}`
)
process.logger?.info(
`Follow these instructions https://cli.sasjs.io/snippets/#import-snippets-to-vs-code to import generated VS Code snippets into your VS Code.`
)

return ReturnCode.Success
})
Expand Down
4 changes: 2 additions & 2 deletions src/commands/snippets/spec/snippets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ describe('sasjs snippets', () => {

it('should return an error if macroFolders array was not provided', async () => {
await expect(generateSnippets()).rejects.toEqual(
'"macroFolders" array was not found in sasjsconfig.json.'
'"macroFolders" array was not found in sasjs/sasjsconfig.json.'
)
})

it('should return an error if macros were not found', async () => {
const config: Configuration = { macroFolders: [emptyMacroFolder] }

await expect(generateSnippets(undefined, config)).rejects.toEqual(
'No snippets has been found.'
'No VS Code snippets has been found.'
)
})
})

0 comments on commit ab8378e

Please sign in to comment.