scripts/deploy.js
// runs for each file object, and uploads to s3
runs for each file object, and uploads to s3
runs for each file object and uploads to s3
function upload(name, callback) {
  var path = './LINEWORK/' + name;
  var name = name;
  if (fs.lstatSync(path).isDirectory()) {
    var archive = archiver('zip');
    var output = fs.createWriteStream(path + '.zip');
    archive.pipe(output);
    output.on('close', function(){
      var object = this;
      var params = {
        localFile: object.path,
        s3Params: {
          Bucket: 'giscollective',
          Key: 'projectlinework/' + name + '.zip',
          ACL: 'public-read'
        },
      };
      var uploader = client.uploadFile(params);
      uploader.on('error', callback);
      uploader.on('progress', function() {
        readline.clearLine(process.stdout, 0);
        readline.cursorTo(process.stdout, 0);
        process.stdout.write(`${name}: ${Math.round(((uploader.progressAmount/uploader.progressTotal)*100)*100)/100}%`);
      });
      uploader.on('end', function() {
        process.stdout.write('\n');
        return callback(null);
      });
    });
    archive.on('error', function(err) {
      throw err;
    });
    archive.bulk([
      { expand: true, cwd: path, src: ['**/*.*'] }
    ]);
    archive.finalize();
  }
}
function upload ( name , callback ) { var path = './LINEWORK/' + name ; var name = name ; if ( fs . lstatSync ( path ) . isDirectory ( ) ) { var archive = archiver ( 'zip' ) ; var output = fs . createWriteStream ( path + '.zip' ) ; archive . pipe ( output ) ; output . on ( 'close' , function ( ) { var object = this ; var params = { localFile : object . path , s3Params : { Bucket : 'giscollective' , Key : 'projectlinework/' + name + '.zip' , ACL : 'public-read' } , } ; var uploader = client . uploadFile ( params ) ; uploader . on ( 'error' , callback ) ; uploader . on ( 'progress' , function ( ) { readline . clearLine ( process . stdout , 0 ) ; readline . cursorTo ( process . stdout , 0 ) ; process . stdout . write ( ` ${ name } ${ Math . round ( ( ( uploader . progressAmount / uploader . progressTotal ) * 100 ) * 100 ) / 100 } ` ) ; } ) ; uploader . on ( 'end' , function ( ) { process . stdout . write ( '\n' ) ; return callback ( null ) ; } ) ; } ) ; archive . on ( 'error' , function ( err ) { throw err ; } ) ; archive . bulk ( [ { expand : true , cwd : path , src : [ '**/*.*' ] } ] ) ; archive . finalize ( ) ; } }
runs for each file object, and uploads to s3
runs for each file object and uploads to s3