index.js
function () {
        fse.emptyDirSync(tmpDir);
        fse.copySync(refSrcDir, tmpDir, { overwrite: true }, err => {
            if (err) {
                console.log(':::~~error in copying to temp directory:' + err + '~~:::');
                fse.removeSync(destFolderDir);
                fse.emptyDirSync(tmpDir);
                deferred.reject('Error in copying to temp directory');
            }
            console.log(':::~~ temp directory created~~:::');
        });
    }
function () {
        fse.emptyDirSync(tmpDir);
        fse.copySync(refSrcDir, tmpDir, { overwrite: true }, err => {
            if (err) {
                console.log(':::~~error in copying to temp directory:' + err + '~~:::');
                fse.removeSync(destFolderDir);
                fse.emptyDirSync(tmpDir);
                deferred.reject('Error in copying to temp directory');
            }
            console.log(':::~~ temp directory created~~:::');
        });
    }
Copy refrence directory in temporary directory