synchronous fs with more fun
npm install fs-syncMaintenance for this project has been discontinued in favor of using fs-extra
----

> Synchronous fs with more fun
fs.xxxSync.Once fs-sync is installed, you can use:
``js
var fs = require('fs-sync');
if(fs.exists('package.json')){
var pkg = fs.readJSON('package.json');
}
`
`js`
var fs = require('fs-sync');
Default value:
'utf-8'Global default encoding
`js
fs.defaultEncoding = 'utf-8'
`$3
Copy a file or a whole directory to the destination. During this, necessary directories will be created.
#### Syntax
`js
fs.copy(file, destpath, options);
fs.copy(dir, destpath, options);
`#### file
Type:
StringPath of file to be copied
#### dir
Type:
StringPath of directory to be copied
#### options.force
Type:
BooleanDefault value:
falseBy default,
fs.copy will not override existed files, set options.force as true to override.
$3
Commandline
mkdir or mkdir -p
$3
Like
grunt.file.expand, but the sequence of the arguments is different
$3
#### options
Type:
ObjectThe same as the
options argument of fs.writeFile$3
Read a file#### options
Type:
ObjectThe same as the
options argument of fs.writeFile, except:#### options.encoding
Type:
StringDefault value:
fs.defaultEncoding$3
Read a file as the JSON format, if the file content fails to be parsed as JSON, an error will be thrown.$3
Delete a file or a whole directory. It's a dangerous action, be careful.
Equivalent to
rm -rf(remove a folder and all its contents) or rm -f(unlink a file)#### Syntax
`js
fs.remove(file)
fs.remove(dir)
`$3
arguments will be called with path.join$3
$3
$3
$3
#### Returns
BooleanWhether the given
path is an absolute path (starting with '/')$3
`js
if(fs.doesPathContain(ancestor, path, path2)){
console.log(path, 'and', path2, 'are inside', ancestor);
}
`#### Returns
BooleanWhether path
ancestor contains all paths after#### ancestor
StringAncestor path
#### path
StringThe arguments of
fs.doesPathContain` could be more than 2.