From b002e354a932e0616adc25e31736dccab81068c0 Mon Sep 17 00:00:00 2001 From: JP Richardson Date: Thu, 17 Dec 2015 08:55:22 -0600 Subject: [PATCH] readme: document copySync. Closes #116 --- README.md | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 082d0e21..1f61efef 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ var fse = require('fs-extra') Methods ------- - [copy](#copy) -- [copySync](#copy) +- [copySync](#copySync) - [createOutputStream](#createoutputstreamfile-options) - [emptyDir](#emptydirdir-callback) - [emptyDirSync](#emptydirdir-callback) @@ -104,10 +104,7 @@ clobber (boolean): overwrite existing file or directory preserveTimestamps (boolean): will set last modification and access times to the ones of the original source files, default is `false`. filter: Function or RegExp to filter copied files. If function, return true to include, false to exclude. If RegExp, same as function, where `filter` is `filter.test`. -Sync: `copySync()` - - -Examples: +Example: ```js var fs = require('fs-extra') @@ -123,6 +120,26 @@ fs.copy('/tmp/mydir', '/tmp/mynewdir', function (err) { }) // copies directory, even if it has subdirectories or files ``` +### copySync() + +**copySync(src, dest, [options])** + +Synchronously copies a file or directory. The directory can have contents. + + +Example: + +```js +var fs = require('fs-extra') + +try { + fs.copySync('/tmp/mydir', '/tmp/mynewdir' +} catch (err) { + console.error('Oh no, there was an error: ' + err.message) +} +``` + + ### createOutputStream(file, [options])