mirror of
https://github.com/wassname/nvatom.git
synced 2026-07-14 01:10:24 +08:00
18 lines
649 B
CoffeeScript
18 lines
649 B
CoffeeScript
path = require 'path'
|
|
fs = require 'fs-plus'
|
|
|
|
module.exports =
|
|
class Utility
|
|
|
|
@getNotePath: (title) -> path.join(Utility.getNoteDirectory(), Utility.trim(title) + Utility.getPrimaryNoteExtension())
|
|
|
|
@getNoteDirectory: -> fs.normalize(atom.config.get('nvatom.directory'))
|
|
|
|
@getPrimaryNoteExtension: -> if atom.config.get('nvatom.extensions').length then atom.config.get('nvatom.extensions')[0] else '.md'
|
|
|
|
@isNote: (filePath) ->
|
|
filePath = fs.normalize(filePath)
|
|
return filePath.startsWith(Utility.getNoteDirectory()) and path.extname(filePath) in atom.config.get('nvatom.extensions')
|
|
|
|
@trim: (str) -> str?.replace /^\s+|\s+$/g, ''
|