Пример #1
0
function copyDir(from, to, cb) {
  console.log('Copying dir ' + from + ' to');
  var files = [];
  fs.walk(from)
    .on('data', function(item) {
      if ((item.stats["mode"] & 0x4000)) {

        var tmp = item.path + '/';
        var l = tmp.length - from.length;
        if (tmp.indexOf(from) == l) return; // #same dir

        console.log('[apply.js.81]', l); //TODO

        console.log('[apply.js.78]', from); //TODO
        // console.log('[apply.js.78]', to); //TODO
        console.log('[apply.js.78]', item.path); //TODO
        console.log('[apply.js.78]', tmp.indexOf(from)); //TODO
      }
      if (item.path.indexOf('DS_Store') >= 0) return;

      files.push(item.path)
    })
    .on('end', function() {
      files.forEach(function(i) {
        console.log(' #    ' + i);
        fs.copySync(i, to + path.basename(i));
      });
      return cb();

    })

}
Пример #2
0
    function createTag(path) {
        let tagName = basename(path);
        let parentTagName = basename(dirname(path));
        // 根目录不作为 tag
        if (basename(ROOT_DIR) === tagName) {
            return;
        }
        // 使第一级 tag 的父目录为空
        if (parentTagName === ROOT_DIR) {
            parentTagName = "";
        }
        let parentsTagNameArray = getParentsTagNameArray(ROOT_DIR, path);
        let tagRank = parentsTagNameArray.length + 1;

        let articleTitleList = [];
        fse.walk(path)
            .on('data', function (item) {
                if (item.stats.isFile()) {
                    // create article and add in articles
                    if (extname(item.path) !== '.md') {
                        return;
                    }

                    let title = getTile(item.path);
                    articleTitleList.push(title);
                }
            });

        return { tagName, parentTagName, articleTitleList, parentsTagNameArray, tagRank };
    }
Пример #3
0
 }).then(() => new Promise((resolve, reject) => {
   fs.ensureDirSync(argv.output);
   const conversions = [];
   fs.walk(argv.suite)
     .on("data", item => {
       if (
         path.extname(item.path) === ".wast" &&
         !argv.excludes.includes(path.basename(item.path, ".wast"))
       ) {
         conversions.push(convertTest(item.path));
       }
       /*
       else if(path.extname(item.path) === ".js") {
         const wastFilePath = path.join(path.dirname(item.path), changeExtension(item.path, ".js", ".wast"));
         conversions.push(
           (new Promise((resolve, reject) => {
             const testDetails = require(item.path);
             fs.writeFile(wastFilePath, `;;AUTO-GENERATED do not modify\n${testDetails}`, err => {
               if (err) {
                 return reject(err);
               }
               resolve();
             });
           }))
           .then(() => convertTest(wastFilePath))
         );
       }*/
     })
     .on("end", () => {
       Promise.all(conversions).then(resolve, reject);
     });
 })).then(() => new Promise((resolve, reject) =>
Пример #4
0
    updateManifest(extensionPath, opts.extensionId, opts.proxy, function (error) {
        if (error) {
            return cb(error);
        }

        var zip = new jszip();
        var zipOpts = { compression: 'deflate' };

        // Zip converted extension
        fs.walk(extensionPath)
        .on('data', function (item) {
            var relPath = path.relative(extensionPath, item.path);
            if (item.stats.isFile()) {
                zip.file(relPath, fs.readFileSync(item.path), zipOpts);
            }
            else if (item.stats.isDirectory()) {
                zip.folder(relPath);
            }
        })
        .on('end', function () {

            if (opts.proxy) {
                // Add our api proxy script to bundle
                zip.file('chrome-apis-proxy.js', fs.readFileSync(apiProxyPath), zipOpts);
            }

            var z = zip.generate({type: 'nodebuffer'});

            // fs.writeFile(opts.outputPath || 'crx2ff.xpi', z, cb);

            return cb(undefined, z);
        });
    });
Пример #5
0
Packager.prototype.includePackagedModules = function (next) {
	console.log('Zipping packaged modules...');
	// Unzip all the zipfiles in support/module/packaged
	var outDir = this.zipDir,
		supportedPlatforms = this.platforms.concat(['commonjs']),
		items = [];
	// Include aliases for ios/iphone/ipad
	if (supportedPlatforms.indexOf('ios') != -1 ||
		supportedPlatforms.indexOf('iphone') != -1 ||
		supportedPlatforms.indexOf('ipad') != -1) {
		supportedPlatforms = supportedPlatforms.concat(['ios', 'iphone', 'ipad']);
	}
	fs.walk(path.join(SUPPORT_DIR, 'module', 'packaged'))
		.on('data', function (item) {
			var m,
				r = /([\w\.]+)?-(\w+)?-([\d\.]+)\.zip$/;
			// Skip modules for platforms we're not bundling!
			if (m = item.path.match(r)) {
				if (supportedPlatforms.indexOf(m[2]) != -1) {
					items.push(item);
				}
			}
		})
		.on('end', function () {
			// MUST RUN IN SERIES or they will clobber each other and unzip will fail mysteriously
			async.eachSeries(items, function (item, cb) {
				unzip(item.path, outDir, function (err) {
					if (err) {
						return cb(err);
					}
					cb();
				});
			}, next);
		});
};
Пример #6
0
  function walkDir(iter) {
    let data = iter.next()
    !data.done && fs.walk(data.value).on('data',function (item) {
      if (path.extname(item.path) === '.desktop') {
        let mtime = item.stats.mtime.getTime(),
            appKey = path.basename(item.path)
        if (mtime > appDb.lastUpdateTime
            || !appDb.apps[appKey]) {
          let appInfo = getAppInfo(item.path)
          tmpApps[appKey] = appInfo
          hasNewApp = true
        }else {
          tmpApps[appKey] = appDb.apps[appKey]
        }
      }
    }).on('end',function () {
      walkDir(iter)
    })

    if(data.done){
      appDb.lastUpdateTime = Date.now()
      appDb.apps = tmpApps
      hasNewApp && fs.outputJSONSync(appDbFile, appDb, 'utf-8')
      if(isFirstIndexing){
        context.notifier.notify('First Indexing Finished! Now Search Your Apps!')
      }
    }
  }
Пример #7
0
    var promise = new Promise(resolve=> {
            var ret = {};
            fs.walk(dir)
                .pipe(filter)
                .on('data', function (item) {
                    var baseName = path.basename(item.path);
                    if (item.stats.isDirectory()) {
                        ret[baseName] = {};
                    }
                    else {
                        var relativeDirs = item.path.replace(dir + '/', '').split('/');
                        relativeDirs.splice(relativeDirs.length - 1, 1);
                        var dirLength = relativeDirs.length;
                        var parent = ret;
                        for (var i = 0; i < dirLength; i++) {
                            parent[relativeDirs[i]] = parent[relativeDirs[i]] || {};
                            parent = parent[relativeDirs[i]];
                        }
                        var extName = path.extname(item.path);
                        var noExtBaseName = path.basename(item.path, extName);
                        var key = noExtBaseName + extName

                        parent[key] = {
                            name: key,
                            relative_name: relativeDirs.join('_') + '_' + noExtBaseName,
                            path: item.path,
                            relative_path: relativeDirs.join('/') + '/' + baseName
                        };
                    }
                })
                .on('end', function () {
                    resolve(ret);
                });
        }
Пример #8
0
 return new Promise((resolve, reject) => {
   fsExtra
     .walk(this.fromPath)
     .on('data', (file) => this._grabMarkdownFile(file))
     .on('end', () => resolve(this.docs))
     .on('error', reject)
 })
Пример #9
0
})('color', ['required', 'copy'], function (config, tempFiles, done) {
  debug('kgo:color')

  fs.walk(config.tmp)
  .on('readable', function () {
    var item
    while ((item = this.read())) {
      if (item.stats.isFile()) {
        let file = item.path
        debug('file: ', file)
        fs.readFile(file, 'utf8', function (err, data) {
          if (err) done(err)
          parser.parseString(data, function (err, result) {
            if (err) debug(err)
            let svgPath = result.svg.path
            svgPath.forEach(function (svg, index, array) {
              debug('file: ', file)
              debug('fill: ', tempFiles[file].fill)
              if (!svg.$.fill) result.svg.path[index].$.fill = tempFiles[file].fill
            })
            let xml = builder.buildObject(result)
            fs.writeFileSync(file, xml, 'utf8')
          })
        })
      }
    }
  })
  .on('end', function () {
    debug(' - done')
    done(null)
  })
})('sprite', ['required', 'color'], function (config, color, done) {
Пример #10
0
exports = module.exports = (app) => {
  var deferred = q.defer();

  var routers = 0;
  fs.walk(path.join(__dirname, 'routes'))
    // Can't use a lambda here. For some reason `this` fails.
    .on('readable', function () {
      var item;
      while ((item = this.read())) {
        if (item.stats.isFile()) {
          LOG.info(` * Found router '${path.basename(item.path).slice(0, -3)}'`);
          app.use('/api/' + path.basename(item.path).slice(0, -3), require(item.path));
          routers++;
        }
      }
    })
    .on('error', (err) => { deferred.reject(err); })
    .on('end', () => {
      app.use('/', require('express').static(path.join(__dirname, '..', 'dist')));
      app.use('/public', require('express').static(path.join(__dirname, '..', 'public')));
      deferred.resolve(app);
    });

  return deferred.promise;
};
Пример #11
0
function fileWalk(startDir, cb)
{
   //Read and return the first file in dir, and the count of which file it is. Only the cnt = 0 is used
   var items = [];
   console.log("Searching:" + startDir);

   if (fsExtra.existsSync(path.normalize(startDir))){
       try {
           var walk = fsExtra.walk(startDir);

	        walk.on('data', function (item) {
	                console.log("Found:" + item.path);
			        items.push(item.path);
		          })
		          .on('end', function () {
			        for(var cnt = 0; cnt< items.length; cnt++) {
				         if(items[cnt].indexOf(".jpg") >= 0) {
					        cb(items[cnt]);
				         	return;
				         }
			        }
			        cb(null);
	          });
	   } catch(err) {
	    console.log("Error reading:" + err);
	    cb(null);
	   }
	} else {
	    cb(null);

	}


}
Пример #12
0
            return new Promise((resolve, reject) => {
                let promises    = [];
                let pgen        = this;
                let rxDir       = new RegExp('^(.+?)\\' + path.sep);        // First directory such as db/
                let rxExtension = new RegExp(`\.${this.fileExtension}$`);   // File name extension such as .nunj.html

                this.logger.info(`Starting to walk template directory: '${this.templateDir}' for target directory '${this.targetDir}'`);

                // Categorize templates based on top level directory relative to template dir.
                fs.walk(pgen.templateDir)
                    .on('readable', function() {
                        let item;
                        while ((item = this.read())) {
                            if (!item.stats.isFile()) { continue; }

                            let template        = item.path;                                                // Ex: .../template/sequelize/table/definition/account.js.nunj
                            let relative        = path.relative(pgen.templateDir, template);                // Ex: table/definition/account.js.nunj
                            let category        = relative.match(rxDir) ? relative.match(rxDir)[1] : null;  // Template root dir: db | schema | table | copy etc.
                            let relativeTarget  = relative.replace(rxDir, '').replace(rxExtension, '');     // Ex: table/definition/account.js.nunj -> definition/account.js.nunj
                            let target          = path.join(pgen.targetDir, relativeTarget);                // Ex: model/definition/account.js.nunj
                            target              = target.replace('#', '|');                                 // Nunucks uses | char for filters, but it's invalid char in windows file names. # is used for filtering, convert # to |;

                            pgen.logger.debug('Template Variables:', { template: template, relative: relative, relativeTarget: relativeTarget, target: target });

                            if (category === 'copy') {
                                promises.push(pgen._copy(template, target));
                                continue;
                            }

                            let extraData = pgen.templateModule && pgen.templateModule.allData ? pgen.templateModule.allData(db) : {};

                            if (category === 'db') {
                                let extraDBData = pgen.templateModule && pgen.templateModule.dbData ? pgen.templateModule.dbData(db) : {};
                                let data = lodash.defaultsDeep({ db: db }, { pgen: getSystemUtils() }, extraDBData, extraData);
                                let interpolatedTarget = nunjucksFileName.renderString(target, data);
                                promises.push(pgen._write(template, interpolatedTarget, data));
                            } else if (category === 'schema') {
                                for (let schema of db.schemas.values()) {
                                    let extraSchemaData = pgen.templateModule && pgen.templateModule.schemaData ? pgen.templateModule.schemaData(schema) : {};
                                    let data = lodash.defaultsDeep({ schema: schema }, { pgen: getSystemUtils() }, extraSchemaData, extraData);
                                    let interpolatedTarget = nunjucksFileName.renderString(target, data);
                                    promises.push(pgen._write(template, interpolatedTarget, data));
                                }
                            } else if (category === 'table') {
                                for (let schema of db.schemas.values()) {
                                    for (let table of schema.tables.values()) {
                                        let extraTableData = pgen.templateModule && pgen.templateModule.tableData ? pgen.templateModule.tableData(table) : {};
                                        let data = lodash.defaultsDeep({ table: table }, { pgen: getSystemUtils() }, extraTableData, extraData);
                                        let interpolatedTarget = nunjucksFileName.renderString(target, data);
                                        promises.push(pgen._write(template, interpolatedTarget, data));
                                    }
                                }
                            }
                        }
                    })
                    .on('end',   ()          => Promise.all(promises).then(() => resolve()).catch((err) => reject(err)))
                    .on('error', (err, item) => reject(new Error(`Template path ${item.path} cannot be processed.\n${err}`)));
            });
Пример #13
0
 return new Promise(function(resolve, reject){
     fse.walk(dirPath, {filter: fsprojFilter})
     .on('data', function(item){
         result.push(item.path);
     })
     .on('end', function(){
         resolve(result);
     })
 });
function rewriteFileNames(){

	//re-write the files names
	fs.emptyDirSync(output_folder, function (err) { })
	fs.emptyDirSync( sprite_imgs );
	fs.emptyDirSync( sprites + '/css');

	//rename files
	var base = __dirname;
	var items = [] // files, directories, symlinks, etc 
	fs.walk(input_folder)
	  .on('data', function (item) {

	  	if(item.stats.isFile()){
	  		items.push(item.path.replace(base + '/', ''))
	  	}
	    
	  })
	  .on('end', function () {
		   // console.dir(items) // => [ ... array of files] 
		    items.forEach(function(f){

		    	var new_file = f.split('/');

		    	new_file[new_file.length - 1] = new_file[new_file.length - 1]
										    	.replace(/å/g, '')
										    	.replace(/ä/g, '')
		    									.replace(/é/g, '')
		    									.replace(/è/g, '')
		    									.replace(/ë/g, '')
		    									.replace(/î/g, '')
		    									.replace(/í/g, '')
		    									.replace(/ü/g, '')
		    									.replace(/Ö/g, '')
		    									.replace(/ö/g, '')
		    									.replace(/ø/g, '')
		    									.replace(/ç/g, '')
		    									.replace(/Ç/g, '')
		    									.replace(/ /g, '')
		    									.replace(/'/g, '')
		    									.replace(/-/g, '');



		    	new_file = new_file.join('/')
		    	
		    	if( new_file != f){
		    		//console.log(new_file, f)
		    		fs.copySync(f, new_file );
		    	}
		    	
		    })
	  })
}
Пример #15
0
 })).then(specFiles => new Promise((resolve) => {
   fs.walk(path.join(argv.suite, "js-api"))
     .on("data", item => {
       if (path.extname(item.path) === ".js") {
         specFiles.push(item.path);
       }
     })
     .on("end", () => {
       resolve(specFiles);
     });
 })).then(specFiles => {
function getTitleList(callback) {
  var baseFolder = fs.realpathSync(folder) ;
  fs.walk(folder)
  .on('data', function (item) {
    if (item.stats.isFile()) {
      functionNames.push(getTitle(item.path));
    }
  })
  .on('end', function () {
    callback(null, functionNames);
  })
}
Пример #17
0
 return new Promise((resolve) => {
   fs.walk(codeDirectory)
     .on('data', (file) => {
       if (!file.stats.isDirectory()) {
         const content = fs.readFileSync(file.path)
         const filePath = file.path.replace(path.join(codeDirectory, path.sep), '')
         zip.file(filePath, content)
       }
     })
     .on('end', () => {
       resolve(zip.generate(options))
     })
 })
Пример #18
0
 var promise = new Promise(function (resolve, reject) {
     fse
         .walk(rootDir)
         .on('data', function (item) {
             if (!helper.excludeFileByPath(item.path, excludeList)) result.push(item.path);
         })
         .on('end', function () {
             return resolve(result);
         })
         .on('error', function (err) {
             return reject(err);
         })
 });
Пример #19
0
	parseDirectory: function(dir) {
		fse.walk(dir).on('data', function(item) {
			if (this.ignored_directories.length > 0) {
				this.ignored_directories.forEach(function(idir, index) {
					if (item.path.search(new RegExp(path.sep + idir + path.sep), 'i') == -1) {
						this.parseFile(item.path);
					}
				}.bind(this));
			}
			else {
				this.parseFile(item.path);
			}
		}.bind(this)).on('end', function() {
			this.done();
		}.bind(this));
	},
 return new Promise((resolve) => {
     let basePath = this.visualPackage.basePath;
     let pathSlash = basePath.indexOf('/') !== -1 ? '/' : '\\';
     let basePathLength = basePath.length;
     //recursively add watchers (linux doesn't support recursive: true for a single watcher)
     fs.walk(basePath).on('data', item => {
         //only watch directories
         if (!item.stats.isDirectory()) { return; }
         //don't watch any hidden folders or their children
         if (item.path.indexOf(pathSlash + '.', basePathLength) !== -1) { return; }
         this.watchers.push(fs.watch(item.path, { recursive: false }, this._fileChangeHandler.bind(this)));
     }).on('end', () => {
         this.watcherInterval = setInterval(this._watchIntervalHandler.bind(this), 500);
         resolve();
     });
 });
Пример #21
0
 }).then(chakraTests => new Promise((resolve) => {
   const specFiles = [...chakraTests];
   fs.walk(path.join(argv.suite, "core"))
     .on("data", item => {
       if (
         path.extname(item.path) === ".wast" &&
         item.path.indexOf(".fail") === -1 &&
         !config.excludes.includes(path.basename(item.path, ".wast"))
       ) {
         specFiles.push(item.path);
       }
     })
     .on("end", () => {
       resolve(specFiles);
     });
 })).then(specFiles => new Promise((resolve) => {
Пример #22
0
/**
 * Processes all the Javascript files within a directory.
 *
 * @param {string} path - the path to process
 * @param {Object} fileProcessor - the processor instance to use to generate code
 * @private
 */
function processDirectory(path, fileProcessor) {
    let items = [];
    fs.walk(path)
        .on('readable', function (item) {
            while ((item = this.read())) {
                if (item.stats.isFile()) {
                    items.push(item.path);
                }
            }
        })
        .on('end', () => {
            items.sort();
            items.forEach((item) => {
                processFile(item, fileProcessor);
            });
        });
}
Пример #23
0
})('sprite', ['required', 'color'], function (config, color, done) {
  debug('kgo:sprite creating sprite')
  const spriter = new SVGSpriter({
    dest: config.output,
    mode: {
      css: {
        render: {
          css: true,
          styl: true
        },
        example: true
      }
    }
  })

  fs.walk(config.tmp)
    .on('readable', function () {
      var item
      while ((item = this.read())) {
        if (item.stats.isFile()) {
          spriter.add(new File({
            path: item.path,                         // Absolute path to the SVG file
            base: config.tmp,                                          // Base path (see `name` argument)
            contents: fs.readFileSync(item.path)     // SVG file contents
          }))
        }
      }
    })
    .on('end', function () {
      spriter.compile(function (err, result, data) {
        if (err) done(err)
        for (var type in result.css) {
          mkdirp.sync(path.dirname(result.css[type].path))
          fs.writeFileSync(result.css[type].path, result.css[type].contents)
        }
      })

      fs.removeSync(config.tmp, function (err) {
        if (err) done(err)
      })

      debug(' - done')
      done(null)
    })
})(['*'], function (err) {
Пример #24
0
	return new Promise(function (resolve, reject) {
		var files = {};
		fs.walk(input).on('data', function (item) {
			if (item.stats.isFile()) {
				var itemPath = parsePath(item.path),
					outputPath = itemPath.replace(input, output + path.sep);
				
				if(typeof walkFn === 'function') {
					outputPath = walkFn(outputPath) || outputPath;
				}
				
				files[item.stats.ino] = {
					input:  itemPath,
					output: outputPath
				};
			}
		}).on('end', function () {
			var counter = 0,
			    parsedPaths = [],
			    length = Object.keys(files).length;

			for (var i = 0; i < length; i++) {
				let current = files[Object.keys(files)[i]];

				fs.readFile(current.input, function (err, content) {
					if (err) {
						reject(err);
					}
					writefile(current.output, _.template(content)(templateData), function (err) {
						if (err) {
							reject(err);
						}
						parsedPaths.push(current.output);

						counter++;
						if (counter == length) {
							resolve(parsedPaths);
						}
					});

				});
			}
		});
	});
Пример #25
0
files.forEach(function (item) {
  var routeConfigFiles = [];
  var routerConfig = require(path.join(mockDir, item));
  if (!routerConfig || typeof routerConfig.path === 'undefined') return;
  routers[item] = {
    config: routerConfig
  };
  fs.walk(path.join(mockDir, item))
    .on('data', function (itemRoute) {
      if (/\.js$/.test(itemRoute.path) && itemRoute.path !== path.join(mockDir, item, 'index.js')) {
        routeConfigFiles.push(itemRoute.path);
      }
    })
    .on('end', function () {
      routers[item].routes = routeConfigFiles;
      if (Object.keys(routers).length === files.length) {
        server(routers);
      }
    });
});
Пример #26
0
exports.load = function(loadpath, matcher, clear, callback) {
    if (clear === true) {
        clearSpecs();
    }

    var wannaBeSpecs = [];
    fse.walk(loadpath)
      .on('data', function(spec) {
        wannaBeSpecs.push(spec.path);
      })
      .on('end', function() {
          for (var i = 0; i < wannaBeSpecs.length; i++) {
              var file = wannaBeSpecs[i];
              if ( shouldLoad(file, matcher) ) {
                  addSpec(file);
              }
          }
          callback();
      });
};
Пример #27
0
      (new Theme(this.options)).install().then((result) => {
        var {
          theme
        } = result;
        if (theme) {
          console.info('Mr. Doc [info]: Installed theme: ' + theme);
        }
        // Make sure the sub dirs that are not blacklisted exist.
        const {
          output, blacklist
        } = this.options,
          sourcePath = Path.normalize(process.cwd() + '/' + this.options.source);

        File.walk(sourcePath)
          .on('readable', function() {
            let item;
            while ((item = this.read())) {
              if (item.stats.isDirectory()) {
                const path = Path.normalize(item
                  .path
                  .replace(sourcePath, output));
                if (blacklist.some(folder => path.indexOf(folder) < 0))
                  File.ensureDirSync(path);
              }
            }
          }).on('end', () => {
            _.forEach(this.files, (file, index) => {
              // Set template
              this.setTemplate(result.template);
              // Compile the template
              let compiled = this.compile(this.locals[index]);
              // Write files
              mkdirp(Path.normalize(this.options.output + '/'), error => {
                if (error) return;
                else File.writeFileSync(Path.join(this.options.output, file.targetName), compiled);
              });
            });
          });


      }, console.error);
Пример #28
0
  , function (result) {
    debug(result)
    const pathToXlsx = path.join(cPath, result.chosenList)



    // const jsonOut = xlsxTradToJson(pathToXlsx, 'adapt-text', '')


    // xlsxTradToJson()
    const xlsxArr = []
    fs.walk(pathToXlsx)
      .on('data', function (item) {
        if (path.parse(item.path).ext === '.xlsx') {
          xlsxArr.push(item.path)
        }
      })
      .on('end', function () {
        debug(xlsxArr)
        self.prompt({
          type: 'list',
          name: 'chosenXlsx',
          message: 'select the dirs you make JSON for',
          choices: xlsxArr
        }
        , function (result) {
          // const jsonOut = xlsxTradToJson(result.chosenXlsx, 'adapt-text', '')

          // debug(path.join(conf.initConf.rcPath, conf.initConf.tradEditFolder))
          const trPath = path.join(conf.rcPath, conf.initConf.tradEditFolder)
          fs.ensureDirSync(trPath)
          debug(result.chosenXlsx)
          // debug(path.join(trPath, 'lang_en', 'trad_en.json'))

          xlsxTradToJson(result.chosenXlsx, 'adapt-text', path.join(trPath, 'lang_en', 'trad_en.json'))
          // cb()
        })
      })

    // cb()
  })
Пример #29
0
Lambda.prototype._zip = function (program, codeDirectory, callback) {

  var options = {
    type: 'nodebuffer',
    compression: 'DEFLATE'
  };

  console.log('=> Zipping repo. This might take up to 30 seconds');
  fs.walk(codeDirectory)
    .on('data', function (file) {
      if (!file.stats.isDirectory()) {
        var content = fs.readFileSync(file.path);
        var filePath = file.path.replace(codeDirectory + '/', '');
        zip.file(filePath, content);
      }
    })
    .on('end', function () {
      var data = zip.generate(options);
      return callback(null, data);
    });
};
Пример #30
0
      return new BbPromise(function(resolve, reject) {
        fse.walk(_this.evt.options.pathDist)
          .on('data', function (item) {
            let symbolicLink = item.stats.isSymbolicLink() && fs.existsSync(item.path);

            if (item.stats.isFile() || symbolicLink) {
              let name = path.relative(_this.evt.options.pathDist, item.path);
              let permissions = fs.statSync(item.path).mode | 0o444;

              // Exclude certain files
              if (name.indexOf('DS_Store') == -1) {
                zip.file(name, fs.readFileSync(item.path), {
                  unixPermissions: permissions
                });
              }
            }
          })
          .on('end', function() {
            resolve();
          })
      })