lib/cli/nodemcu-tool.js
async function download(remoteFile){
    // strip path
    let localFilename = _path.basename(remoteFile);

    // local file with same name already available ?
    if (await _fs.exists(remoteFile)){
        // change filename
        localFilename += '.' + (new Date().getTime());

        _logger.log('Local file "' + remoteFile + '" already exist - new file renamed to "' + localFilename + '"');
    }

    // try to establish a connection to the module
    await getConnection();

    _logger.log('Downloading "' + remoteFile + '" ...');

    let data = null;

    // download the file
    try{
        data = await _nodeMcuConnector.download(remoteFile);
        _logger.log('Data Transfer complete!');

    }catch(e){
        _logger.debug(e);
        throw new Error('Data Transfer FAILED!');
    }

    // store the file
    try{
        await _fs.writeFile(localFilename, data);
        _logger.log('File "' + localFilename + '" created');
    }catch(e){
        _logger.debug(e);
        throw new Error('i/o error - cannot save file');
    }
}
async function download(remoteFile){
    // strip path
    let localFilename = _path.basename(remoteFile);

    // local file with same name already available ?
    if (await _fs.exists(remoteFile)){
        // change filename
        localFilename += '.' + (new Date().getTime());

        _logger.log('Local file "' + remoteFile + '" already exist - new file renamed to "' + localFilename + '"');
    }

    // try to establish a connection to the module
    await getConnection();

    _logger.log('Downloading "' + remoteFile + '" ...');

    let data = null;

    // download the file
    try{
        data = await _nodeMcuConnector.download(remoteFile);
        _logger.log('Data Transfer complete!');

    }catch(e){
        _logger.debug(e);
        throw new Error('Data Transfer FAILED!');
    }

    // store the file
    try{
        await _fs.writeFile(localFilename, data);
        _logger.log('File "' + localFilename + '" created');
    }catch(e){
        _logger.debug(e);
        throw new Error('i/o error - cannot save file');
    }
}
async function download ( remoteFile ) { // strip path let localFilename = _path . basename ( remoteFile ) ; // local file with same name already available ? if ( await _fs . exists ( remoteFile ) ) { // change filename localFilename += '.' + ( new Date ( ) . getTime ( ) ) ; _logger . log ( 'Local file "' + remoteFile + '" already exist - new file renamed to "' + localFilename + '"' ) ; } // try to establish a connection to the module await getConnection ( ) ; _logger . log ( 'Downloading "' + remoteFile + '" ...' ) ; let data = null ; // download the file try { data = await _nodeMcuConnector . download ( remoteFile ) ; _logger . log ( 'Data Transfer complete!' ) ; } catch ( e ) { _logger . debug ( e ) ; throw new Error ( 'Data Transfer FAILED!' ) ; } // store the file try { await _fs . writeFile ( localFilename , data ) ; _logger . log ( 'File "' + localFilename + '" created' ) ; } catch ( e ) { _logger . debug ( e ) ; throw new Error ( 'i/o error - cannot save file' ) ; } }
download a remote file from nodemcu
download a remote file from nodemcu