lib/functions/downloadIncludedFiles.js
function getAndWriteIncludedFile(file, includeDir) {
    return new Promise((resolve, reject) => {
        const fileName = file[0];
        const fileURL = file[1];

        const options = {
            url: fileURL,
            headers: {
                'User-Agent': 'request',
            },
        };

        request.get(options, (err, response, body) => {
            if (!err && response.statusCode === 200) {
                fs.writeFile(path.join(includeDir, fileName), body, (writeErr) => {
                    if (writeErr) {
                        resolve({
                            fileName,
                            successful: false,
                        });
                    } else {
                        resolve({
                            fileName,
                            successful: true,
                        });
                    }
                    return;
                });
            } else {
                resolve({
                    fileName,
                    successful: false,
                });
                return;
            }
        });
    });
}
function getAndWriteIncludedFile(file, includeDir) {
    return new Promise((resolve, reject) => {
        const fileName = file[0];
        const fileURL = file[1];

        const options = {
            url: fileURL,
            headers: {
                'User-Agent': 'request',
            },
        };

        request.get(options, (err, response, body) => {
            if (!err && response.statusCode === 200) {
                fs.writeFile(path.join(includeDir, fileName), body, (writeErr) => {
                    if (writeErr) {
                        resolve({
                            fileName,
                            successful: false,
                        });
                    } else {
                        resolve({
                            fileName,
                            successful: true,
                        });
                    }
                    return;
                });
            } else {
                resolve({
                    fileName,
                    successful: false,
                });
                return;
            }
        });
    });
}
function getAndWriteIncludedFile ( file , includeDir ) { return new Promise ( ( resolve , reject ) => { const fileName = file [ 0 ] ; const fileURL = file [ 1 ] ; const options = { url : fileURL , headers : { 'User-Agent' : 'request' , } , } ; request . get ( options , ( err , response , body ) => { if ( ! err && response . statusCode === 200 ) { fs . writeFile ( path . join ( includeDir , fileName ) , body , ( writeErr ) => { if ( writeErr ) { resolve ( { fileName , successful : false , } ) ; } else { resolve ( { fileName , successful : true , } ) ; } return ; } ) ; } else { resolve ( { fileName , successful : false , } ) ; return ; } } ) ; } ) ; }
Get and write all included files

@param {Object} file - File to get and write.
@param {String} includeDir - Where to write the included files.
@returns {Promise} - Promise resolving an object with the fileName and if include was successful
Get and write all included files