jcinfo-utils 1.0.33 → 1.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -73,3 +73,5 @@ export function updateDotEnv(
73
73
  export function updateVersionDate(fs: any, filename?: string): void
74
74
 
75
75
  export function retirarAcentuacao(value: string): string
76
+
77
+ export function fileExists(filename: string): boolean
package/index.js CHANGED
@@ -13,6 +13,7 @@ import { updateDotEnv } from './src/updateDotEnv.js'
13
13
  import { formatFileSize } from './src/formatFileSize.js'
14
14
  import { updateVersionDate } from './src/updateVersionDate.js'
15
15
  import { retirarAcentuacao } from './src/retirarAcentuacao.js'
16
+ import { fileExists } from './src/utils.js'
16
17
 
17
18
  // ===================================================== LOGS
18
19
 
@@ -220,4 +221,5 @@ export {
220
221
  updateDotEnv,
221
222
  updateVersionDate,
222
223
  retirarAcentuacao,
224
+ fileExists,
223
225
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jcinfo-utils",
3
- "version": "1.0.33",
3
+ "version": "1.0.34",
4
4
  "description": "Pacote de funções utilitárias",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/utils.js ADDED
@@ -0,0 +1,12 @@
1
+ import fs from 'node:fs'
2
+
3
+ export function fileExists(filename) {
4
+ try {
5
+ // Verifica se o arquivo existe usando fs.accessSync
6
+ fs.accessSync(filename, fs.constants.F_OK)
7
+ return true
8
+ } catch (err) {
9
+ // Se ocorrer um erro, o arquivo não existe ou não é acessível
10
+ return false
11
+ }
12
+ }
package/test/testar.js CHANGED
@@ -91,4 +91,8 @@ updateVersionDate(fs)
91
91
  console.log('')
92
92
 
93
93
  console.log(retirarAcentuacao('Criança, mãe, João, MÃE, anão, ANÃO'))
94
+
95
+ const arq = '.env'
96
+ console.log('Arquivo existe?', jc.fileExists(arq))
97
+
94
98
  console.groupEnd()