src/copy.js
function copyFileIntoDirectory(srcPath, destPath) {
        return ensureDestinationDirectory(destPath).then(function () {
            return new Promise(function (resolve, reject) {
                fs.readFile(srcPath, 'utf8', function (err, contents) {
                    if (!err) {
                        resolve();
                    } else {
                        reject(err);
                    }
                    fs.outputFile(destPath + '/' + path.basename(srcPath), contents, function (err) {
                        if (!err) {
                            resolve();
                        } else {
                            reject(err);
                        }
                    });
                });
            });
        });
    }
function copyFileIntoDirectory(srcPath, destPath) {
        return ensureDestinationDirectory(destPath).then(function () {
            return new Promise(function (resolve, reject) {
                fs.readFile(srcPath, 'utf8', function (err, contents) {
                    if (!err) {
                        resolve();
                    } else {
                        reject(err);
                    }
                    fs.outputFile(destPath + '/' + path.basename(srcPath), contents, function (err) {
                        if (!err) {
                            resolve();
                        } else {
                            reject(err);
                        }
                    });
                });
            });
        });
    }
function copyFileIntoDirectory ( srcPath , destPath ) { return ensureDestinationDirectory ( destPath ) . then ( function ( ) { return new Promise ( function ( resolve , reject ) { fs . readFile ( srcPath , 'utf8' , function ( err , contents ) { if ( ! err ) { resolve ( ) ; } else { reject ( err ) ; } fs . outputFile ( destPath + '/' + path . basename ( srcPath ) , contents , function ( err ) { if ( ! err ) { resolve ( ) ; } else { reject ( err ) ; } } ) ; } ) ; } ) ; } ) ; }
Copies a file into a directory.
@param {String} srcPath - source path
@param {String} destPath - destination path
@returns {Promise} Returns a promise when completed
Copies a file into a directory .