Пример #1
0
Project.prototype.demeteorize = function(dir, nodeVersion, meteorDebug, meteorPrerelease, callback) {
  var out = path.join(dir, '.demeteorized'),
    nodeVersion =  nodeVersion || 'v0.10.22';

  if(fs.existsSync(out)) {
    fsTools.removeSync(out);
  }

  demeteorizer.convert(
    dir,
    out,
    nodeVersion,
    null,  // release
    false, // tarball
    null,  // appName
    !!meteorPrerelease,
    !!meteorDebug,
    function(err) {
      if(err) {
        callback(err);
      }
      else {
        callback(null, out);
      }
    });
};
Пример #2
0
 files.forEach(function(file) {
   var stat = fs.statSync(path.join(folder, file));
   if(stat.isDirectory() && file === 'node_modules') {
     FsTools.removeSync(path.join(folder, file));
   }
   else if(stat.isDirectory()) {
     self.deleteNodeModulesDir(path.join(folder, file));
   }
 });
  function (err) {

  if (err) {
    console.error(err);
    process.exit(1);
  }

  console.log('Creating font file');

  _.each(config.glyphs, function (glyph) {
    var fileName = glyph.file || glyph.css + '.svg';
    var svg = parseSvgImage(fs.readFileSync(path.resolve(tmpDir, fileName), 'utf8'), fileName);

    glyph.width = svg.width;
    glyph.d = svg.d;

    // Fix for FontForge: need space between old and new polyline
    glyph.d = glyph.d.replace(/zm/g, 'z m');

    // Round all values to int
    //glyph.d = glyph.d.replace(
    //  /\d+\.\d+/g,
    //  function (match) {
    //    if (+match > 100) {
    //      return Number(match).toFixed(0) + '';
    //    }
    //    return Number(match).toFixed(1) + '';
    //  }
    //);


    // 'unicode' attribute can be number in hex format, or ligature
    if (glyph.code === +glyph.code) {
      glyph.unicode = '&#x' + glyph.code.toString(16) + ';';
    } else {
      glyph.unicode = glyph.code;
    }
  });

  var svgOut = svgFontTemplate({
    font : font,
    glyphs : config.glyphs,
    metadata : font.copyright || "Generated by fontello.com",
    fontHeight : font.ascent - font.descent,
    fontFamily : font.familyname || "myfont",
    fontWeight : font.weight || "normal"
  });

  fs.writeFileSync(args.output, svgOut, 'utf8');

  fstools.removeSync(tmpDir);
});
Пример #4
0
    process.on('exit', function (code) {
      if (0 !== +code) {
        console.warn('Unclean exit. Bundled files left in \'' + tmpdir + '\'');
        return;
      }

      try {
        N.logger.debug('Removing %s ...', tmpdir);
        fstools.removeSync(tmpdir);
      } catch (err) {
        N.logger.error('Failed to remove %s, %s ', tmpdir, String(err));
      }
    });
Пример #5
0
        projectController._deploy(projectId, zipFile, forceNpmInstall, registry, function(err, domain) {
          fs.unlinkSync(zipFile);

          //Removes the .demeteorized folder
          if(projectType === Project.types.METEOR) {
            fsTools.removeSync(path);
          }

          if(err) {
            console.log(); //provides a newline
            return cb(err, null);
          }

          cb(null, domain);
        });
Пример #6
0
// Write data String/Buffer into filename
function write(filename, mtime, data) {
  var tempname = filename + '+';

  try {
    fstools.mkdirSync(path.dirname(filename));
    fs.writeFileSync(tempname, toBuffer(data));
    fs.renameSync(tempname, filename);
    fs.utimesSync(filename, mtime, mtime);
  } catch (err) {
    // Try to remove tmp file on error.
    // Don't check if exists, just suppress errors
    try { fstools.removeSync(tempname); } catch (__) {}

    throw err;
  }
}
Пример #7
0
Project.prototype.demeteorize = function(dir, nodeVersion, callback) {
  var out = path.join(dir, '.demeteorized'),
      nodeVersion =  nodeVersion || 'v0.10.22';

  if(fs.existsSync(out)) {
    fsTools.removeSync(out);
  }

  demeteorizer.convert(dir, out, nodeVersion, null, function(err) {
    if(err) {
      callback(err);
    }
    else {
      callback(null, out);
    }
  });
};
Project.prototype.demeteorize = function(dir, nodeVersion, meteorDebug, meteorPrerelease, callback) {
  var out = path.join(dir, '.demeteorized'),
    nodeVersion =  nodeVersion || 'v0.10.22';

  if(fs.existsSync(out)) {
    fsTools.removeSync(out);
  }

  demeteorizer.convert({
    input      : dir,
    output     : out,
    prerelease : !!meteorPrerelease,
    debug      : !!meteorDebug
  },
  function(err) {
    if(err) {
      callback(err);
    }
    else {
      callback(null, out);
    }
  });
};
Пример #9
0
module.exports = function (sandbox) {
  var N           = sandbox.N
    , timer       = stopwatch()
    , environment = sandbox.assets.environment
    , outdir      = path.join(N.mainApp.root, 'public/assets')
    , manifest    = null
    , fileslist   = null;

  //
  // Check assets integtity - ones, used via helpers must exists
  // in `bin` section of `bundle.yml`. If not exists, we'll get
  // 404 errors on client
  //
  var missed =  _.find(sandbox.assets.used, function(assetPath) {
    return -1 === sandbox.assets.files.indexOf(assetPath) ? true : false;
  });

  if (missed) {
    // Purge cache, to force full recompile on next restart.
    // In other case, helpers call can be missed and we will not check
    // if paths are correct
    fstools.removeSync(N.config.options.cache_dir);

    throw new Error(format(
      'Error in "bundle.yml": section "bin" miss search path for "%s"',
      missed
    ));
  }


  //
  // Normalize filenames (loader.js.ejs -> loader.js)
  // needed for proper caching by environment.index
  //

  fileslist = _(sandbox.assets.files)
    .map(function (f) {
      return (environment.findAsset(f) || {}).logicalPath;
    })
    .filter(Boolean).uniq()
    .valueOf();

  //
  // make environment hardly cached. Init manifest.
  //

  environment = environment.index;
  manifest    = new Mincer.Manifest(environment, outdir);

  //
  // run compiler
  //
  var data = manifest.compile(fileslist, {
    compress: false,
    sourceMaps: true,
    embedMappingComments: true
  });

  var logger = N.logger.getLogger('*****@*****.**');
  var server = new Mincer.Server(environment, data);

  //
  // Formats and writes log event into our logger
  //

  server.log = function logAssets(level, event) {
    logger[level]('%s - "%s %s HTTP/%s" %d "%s" - %s',
                  event.remoteAddress,
                  event.method,
                  event.request.originalUrl || event.url,
                  event.httpVersion,
                  event.code,
                  event.headers['user-agent'] || '',
                  event.message);
  };

  N.assets = {
    distribution: sandbox.assets.distribution,
    environment:  environment,
    manifest:     data,
    server:       server
  };

  N.logger.info('Processed text macroces and binary files %s', timer.elapsed);
};
Пример #10
0
  _.keys(sandbox.config.packages).forEach(function (pkgName) {
    var clientConfig = sandbox.config.packages[pkgName].client
      , mainLookup   = null
      , resultFile   = path.join(tmpdir, 'client', pkgName + '.js')
      , clientTmpDir = path.join(tmpdir, 'client', pkgName)
      , mainFile     = path.join(clientTmpDir, 'main.js')
      , modulesFile  = path.join(clientTmpDir, 'client.js')
      , targetFile   = null // mainFile if exists; modulesFile otherwise.
      , environment  = sandbox.assets.environment
      , originPaths  = environment.paths // to restore it later
      , timer        = stopwatch();

    if (_.isEmpty(clientConfig)) {
      return;
    }

    mainLookup = _.find(clientConfig, 'main');

    if (mainLookup) {
      browserifyMainFile(sandbox, pkgName, path.resolve(mainLookup.root, mainLookup.main), mainFile);
      targetFile = mainFile;
    } else {
      targetFile = modulesFile;
    }

    browserifyFiles(sandbox, pkgName, clientConfig, modulesFile);

    // Prepend path with `modulesFile` to allow use
    //
    //    //= require client
    //
    // in main file.
    environment.prependPath(clientTmpDir);

    // When Mincer is asked for a main file, it must be within roots, that
    // Mincer knows about. See: https://github.com/nodeca/mincer/issues/51
    clientConfig.forEach(function (options) {
      environment.appendPath(options.root);
    });

    // Find & build asset
    var asset = environment.findAsset(targetFile);

    // Check that main file is requirable.
    if (!asset) {
      // Restore Mincer's paths.
      environment.clearPaths();
      environment.appendPath(originPaths);

      throw new Error('Main client file of ' + pkgName + ' not found: ' + targetFile);
    }

    var source = asset.buffer.toString();

    fs.writeFileSync(resultFile, source, 'utf8');

    // Restore Mincer's paths.
    environment.clearPaths();
    environment.appendPath(originPaths);

    N.logger.debug('Compiled client of %s %s', pkgName, timer.elapsed);
    fstools.removeSync(clientTmpDir);
  });
Пример #11
0
  _.keys(sandbox.config.packages).forEach(function (pkgName) {
    var stylesConfig  = sandbox.config.packages[pkgName].styles
      , stylesTmpDir  = path.join(tmpdir, 'styles', pkgName)
      , stylesTmpFile = path.join(stylesTmpDir, 'styles.css')
      , targetFile    = null
      , resultFile    = path.join(tmpdir, 'styles', pkgName + '.css')
      , environment   = sandbox.assets.environment
      , originPaths   = environment.paths // to restore it later
      , timer         = stopwatch();

    if (_.isEmpty(stylesConfig)) {
      return;
    }

    joinStyles(stylesConfig, stylesTmpFile, {
      pkgName:  pkgName
    , packages: sandbox.config.packages
    , cacheDir: cacheDir
    });

    // Use `main` file, if exists. Otherwise use concatenated styles file only.
    if (_.find(stylesConfig, 'main')) {
      targetFile = _.find(stylesConfig, 'main').main;
    } else {
      targetFile = stylesTmpFile;
    }

    // Prepend path with styles tree to allow use
    //
    //    //= require styles
    //
    // in main file.
    environment.prependPath(stylesTmpDir);

    // When Mincer is asked for a main file, it must be within roots, that
    // Mincer knows about. See: https://github.com/nodeca/mincer/issues/51
    stylesConfig.forEach(function (options) {
      environment.appendPath(options.root);
    });

    // Find & build asset
    var asset = environment.findAsset(targetFile);

    // Check that main file is requirable.
    if (!asset) {
      // Restore Mincer's paths.
      environment.clearPaths();
      environment.appendPath(originPaths);
      throw new Error('Main style file of ' + pkgName + ' not found: ' + targetFile);
    }

    // Write main file.
    fs.writeFileSync(resultFile, asset.buffer, 'utf8');

    // restore mincer's paths
    environment.clearPaths();
    environment.appendPath(originPaths);

    N.logger.debug('Compiled styles of %s %s', pkgName, timer.elapsed);
    fstools.removeSync(stylesTmpDir);
  });