lib/functions/pack.js
function getFileJSON(rootFolder, file, fileName, extension, id) {
    return new Promise((resolve, reject) => {
        fs.stat(path.join(rootFolder, file), (err, stats) => {
            if (err) {
                reject();
                return;
            }
            if (stats.isFile()) {
                // Read local javascript file
                fs.readFile(path.join(rootFolder, file), 'utf8', (err, source) => {
                    if (err) {
                        reject(err);
                        return;
                    }

                    const type = eaft.getFiletypeFromExtension(extension);
                    const fileJSON = {
                        name: fileName,
                        type,
                        source,
                        id,
                    };

                    resolve(fileJSON);
                    return;
                });
            } else {
                reject();
                return;
            }
        });
    });
}
function getFileJSON(rootFolder, file, fileName, extension, id) {
    return new Promise((resolve, reject) => {
        fs.stat(path.join(rootFolder, file), (err, stats) => {
            if (err) {
                reject();
                return;
            }
            if (stats.isFile()) {
                // Read local javascript file
                fs.readFile(path.join(rootFolder, file), 'utf8', (err, source) => {
                    if (err) {
                        reject(err);
                        return;
                    }

                    const type = eaft.getFiletypeFromExtension(extension);
                    const fileJSON = {
                        name: fileName,
                        type,
                        source,
                        id,
                    };

                    resolve(fileJSON);
                    return;
                });
            } else {
                reject();
                return;
            }
        });
    });
}
function getFileJSON ( rootFolder , file , fileName , extension , id ) { return new Promise ( ( resolve , reject ) => { fs . stat ( path . join ( rootFolder , file ) , ( err , stats ) => { if ( err ) { reject ( ) ; return ; } if ( stats . isFile ( ) ) { // Read local javascript file fs . readFile ( path . join ( rootFolder , file ) , 'utf8' , ( err , source ) => { if ( err ) { reject ( err ) ; return ; } const type = eaft . getFiletypeFromExtension ( extension ) ; const fileJSON = { name : fileName , type , source , id , } ; resolve ( fileJSON ) ; return ; } ) ; } else { reject ( ) ; return ; } } ) ; } ) ; }
Getting the json form of a file.

@param {String} rootFolder - relative path to the rootFOldr of the project.
@param {String} file - Full filename of the file to process.
@param {String} fileName - fileName without extension.
@param {String} extension - Only the extension of the filename.
@param {String} id - Optional id of the file in the remote project.
@returns {Promise} - Promise resolving the json form of the file
Getting the json form of a file .