als-fo
v0.5.4
Published
Collection of usefull operations with files.
Downloads
4
Readme
als-fo (file operations)
New in V0.5
- Added delay to fo.watch to prevent runing fn twice on windows
- Fixed
fo.delete
- Added
fo.changeExt
New in V0.5.1
- Added
fo.isFile
New in V0.5.3
- Added
fo.buildFile
- Fixed filtering by extension in
getFilesList
Collection of usefull operations with files.
let fo = require('als-fo)
// If obj can be stringified, returned stringified.
fo.isJson(obj)
// Checking if path array and return joined path or return path
fo.path(path)
// Checking if obj is json and stringify it. Writing the file to path. Path checked by fo.path.
fo.writeFile(path,obj,encoding = 'utf-8')
// Readigng file, if json return object. Path checked by fo.path.
fo.readFile(path,encoding = 'utf-8')
// If path exists, return true. Else return false. Path checked by fo.path.
fo.isExist(path)
// Check if module exists, deleting cache and return required module
fo.require(path) // if not exists return empty object
// Checking if folder for path are existen. Creating file with fo.path and fo.isJson
// If where givemt console.log(result)
fo.createPath(path,content,where='')
// If folder not exists, create it.
fo.makeDir(dir)
// Removing dirToRemove, adding host and replace \ to /
fo.urlFromPath(path,dirToRemove,host)
// Wathing given folder(dir) and runs function(fn) then change occures. fn(event,filename)
fo.watchDir(dir,fn)
// Runs recursevly and return list of files in given folder(dir) and it's subfolders with given extension (ext).
// If extension not given, return all files in folder and it's subfolders.
// ignore array will include path of files to ignore
fo.getFilesList(dir,ext,ignore=[],filelist = [])
// if path has this extension return true, else return extension of given path
fo.ext(path,ext)
// Runs fo.getFilesList and get all files. Then add it to mainList (has to be array)
fo.addToList(path,mainList)
// Just return time in hh:mm:ss
fo.now()
// return path creation date
fo.fileDate(path)
// delete the path
fo.delete(path)
// recursive copy files and foldre from src to dest
fo.copy(src, dest)
// Checks if path is directory. Retrun true if directory and false if not
fo.isDir(path)
// Checks if path is file. Retrun true if file and false if not
fo.isFile(path)
// If cli has 'order' parameter return fn(argv). else return error to console
fo.cli(order,fn,error)
// return capitalized string
fo.upperFirst(string)
// Changing extension of file to newExt(without dot). path can be array (fo.path)
fo.changeExt(path,newExt)
// if srcFilePath is js file: fo.require(srcFilePath). if content is function running function if error, content = ''.
// hooks will include functions with parameters (content,srcFilePath) and has to return content (string)
fo.buildFile(srcFilePath,hooks=[])