mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
fixed eslint error
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
const { remote } = require('electron')
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import crypto from 'crypto'
|
||||
import consts from 'browser/lib/consts'
|
||||
|
||||
function createSnippet(snippets) {
|
||||
function createSnippet (snippets) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const newSnippet = {
|
||||
id: crypto.randomBytes(16).toString('hex'),
|
||||
const newSnippet = {
|
||||
id: crypto.randomBytes(16).toString('hex'),
|
||||
name: 'Unnamed snippet',
|
||||
prefix: [],
|
||||
content: ''
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
const { remote } = require('electron')
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import consts from 'browser/lib/consts'
|
||||
|
||||
function deleteSnippet (snippets, snippetId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
for(let i = 0; i < snippets.length; i++) {
|
||||
for (let i = 0; i < snippets.length; i++) {
|
||||
if (snippets[i].id === snippetId) {
|
||||
snippets.splice(i, 1);
|
||||
snippets.splice(i, 1)
|
||||
fs.writeFile(consts.SNIPPET_FILE, JSON.stringify(snippets, null, 4), (err) => {
|
||||
if (err) reject(err)
|
||||
resolve(snippets)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = deleteSnippet
|
||||
module.exports = deleteSnippet
|
||||
|
||||
@@ -3,10 +3,10 @@ import consts from 'browser/lib/consts'
|
||||
|
||||
function updateSnippet (snippet) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let snippets = JSON.parse(fs.readFileSync(consts.SNIPPET_FILE, 'utf-8'))
|
||||
const snippets = JSON.parse(fs.readFileSync(consts.SNIPPET_FILE, 'utf-8'))
|
||||
|
||||
for (let i = 0; i < snippets.length; i++) {
|
||||
let currentSnippet = snippets[i]
|
||||
const currentSnippet = snippets[i]
|
||||
|
||||
if (currentSnippet.id === snippet.id) {
|
||||
if (
|
||||
@@ -20,7 +20,6 @@ function updateSnippet (snippet) {
|
||||
currentSnippet.name = snippet.name
|
||||
currentSnippet.prefix = snippet.prefix
|
||||
currentSnippet.content = snippet.content
|
||||
|
||||
fs.writeFile(consts.SNIPPET_FILE, JSON.stringify(snippets, null, 4), (err) => {
|
||||
if (err) reject(err)
|
||||
resolve(snippets)
|
||||
|
||||
Reference in New Issue
Block a user