Skip to content

Commit e101906

Browse files
Merge branch 'hotfix/1.3.10'
2 parents cbd19c8 + c5bb165 commit e101906

File tree

5 files changed

+30
-15
lines changed

5 files changed

+30
-15
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"automating-code-creation",
1010
"code-generation"
1111
],
12-
"version": "1.3.9",
12+
"version": "1.3.10",
1313
"license": "ISC",
1414
"bin": {
1515
"create-snippet": "./dist/bin/index.js"

src/enums/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from './prefix-name.enum'
22
export * from './snippet-name.enum'
33
export * from './snippet-variable.enum'
44
export * from './suffix-name.enum'
5+
export * from './symbol.enum'

src/enums/symbol.enum.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const enumSymbol = {
2+
check: '√',
3+
cross: 'x',
4+
}

src/modules/config/config.module.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import chalk from 'chalk'
22
import fs from 'fs'
33
import path from 'path'
44
import { CONSTANTS } from '../../constants'
5-
import { enumPrefixName, enumSnippetName, enumSuffixName } from '../../enums'
5+
import { enumPrefixName, enumSnippetName, enumSuffixName, enumSymbol } from '../../enums'
66
import { TypeCase, TypeConfig } from '../../types'
77
import { InterfaceConfig } from './config.interface'
88

@@ -71,7 +71,9 @@ ${objectToString(enumSnippetName)}
7171
})
7272

7373
// eslint-disable-next-line no-console
74-
console.log(`${chalk.green(`√`)} ${chalk.gray(`the project has been successfully initialized`)}`)
74+
console.log(
75+
`${chalk.green(enumSymbol.check)} ${chalk.gray(`the project has been successfully initialized`)}`
76+
)
7577
}
7678

7779
public get() {

src/modules/snippet/snippet.module.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import nodePath from 'path'
44
import { prompt } from 'prompts'
55
import recursiveReadDir from 'recursive-readdir'
66
import { CONSTANTS } from '../../constants'
7-
import { enumPrefixName, enumSnippetName, enumSnippetVariable, enumSuffixName } from '../../enums'
7+
import { enumPrefixName, enumSnippetName, enumSnippetVariable, enumSuffixName, enumSymbol } from '../../enums'
88
import type { TypeCase, TypeStringConversionMethod } from '../../types'
99
import { ModuleConfig } from '../config'
1010
import { ModulePath } from '../path'
@@ -177,17 +177,25 @@ export class ModuleSnippet {
177177
paths.forEach((pathToSnippet) => {
178178
const data = this.formatSnippet(pathToSnippet)
179179
const myPath = this.modulePath.generate({ config, name, path, pathToSnippet })
180-
if (this.isSnippet(myPath.pathWriteSnippetFile)) throw new Error('isSnippet')
181-
if (this.isSnippet(myPath.pathFlatWriteSnippetFile)) throw new Error('isSnippet')
182-
fs.mkdirSync(this.options.isFlat ? myPath.pathFlatSnippetFile : myPath.pathSnippetFile, {
183-
recursive: true,
184-
})
185-
fs.writeFileSync(
186-
this.options.isFlat ? myPath.pathFlatWriteSnippetFile : myPath.pathWriteSnippetFile,
187-
data
188-
)
189-
// eslint-disable-next-line no-console
190-
console.log(`${chalk.green(`√`)} ${chalk.gray(myPath.snippetFileName)}`)
180+
const pathSnippetFile = this.options.isFlat ? myPath.pathFlatSnippetFile : myPath.pathSnippetFile
181+
const pathWriteSnippetFile = this.options.isFlat
182+
? myPath.pathFlatWriteSnippetFile
183+
: myPath.pathWriteSnippetFile
184+
if (this.isSnippet(pathWriteSnippetFile)) {
185+
// eslint-disable-next-line no-console
186+
console.log(
187+
`${chalk.red(enumSymbol.cross)} ${chalk.gray(
188+
`The files ${myPath.snippetFileName} on the path ${pathWriteSnippetFile} already exist`
189+
)}`
190+
)
191+
} else {
192+
fs.mkdirSync(pathSnippetFile, {
193+
recursive: true,
194+
})
195+
fs.writeFileSync(pathWriteSnippetFile, data)
196+
// eslint-disable-next-line no-console
197+
console.log(`${chalk.green(enumSymbol.check)} ${chalk.gray(myPath.snippetFileName)}`)
198+
}
191199
})
192200
})
193201
}

0 commit comments

Comments
 (0)