build.js
function replaceVersionsObservable(name, versions) {
  return Observable.create((observer) => {
    const package = getSrcPackageFile(name);
    let pkg = readFileSync(package, 'utf8');
    const regexs = Object.keys(versions).map(key =>
      ({ expr: new RegExp(key, 'g'), key, val: versions[key] }));
    regexs.forEach(reg => {
      pkg = pkg.replace(reg.expr, reg.val);
    });
    const outPath = getDestPackageFile(name);
    writeFile(outPath, pkg, err => {
      if (err) {
        observer.error(err);
      } else {
        observer.next(pkg);
        observer.complete();
      }
    });
  });
}
function replaceVersionsObservable(name, versions) {
  return Observable.create((observer) => {
    const package = getSrcPackageFile(name);
    let pkg = readFileSync(package, 'utf8');
    const regexs = Object.keys(versions).map(key =>
      ({ expr: new RegExp(key, 'g'), key, val: versions[key] }));
    regexs.forEach(reg => {
      pkg = pkg.replace(reg.expr, reg.val);
    });
    const outPath = getDestPackageFile(name);
    writeFile(outPath, pkg, err => {
      if (err) {
        observer.error(err);
      } else {
        observer.next(pkg);
        observer.complete();
      }
    });
  });
}
function replaceVersionsObservable ( name , versions ) { return Observable . create ( ( observer ) => { const package = getSrcPackageFile ( name ) ; let pkg = readFileSync ( package , 'utf8' ) ; const regexs = Object . keys ( versions ) . map ( key => ( { expr : new RegExp ( key , 'g' ) , key , val : versions [ key ] } ) ) ; regexs . forEach ( reg => { pkg = pkg . replace ( reg . expr , reg . val ) ; } ) ; const outPath = getDestPackageFile ( name ) ; writeFile ( outPath , pkg , err => { if ( err ) { observer . error ( err ) ; } else { observer . next ( pkg ) ; observer . complete ( ) ; } } ) ; } ) ; }
Create an observable of package.json dependency version replacements.
This keeps the dependency versions across each package in sync.
@param {string} name
@param {Object} versions
Create an observable of package . json dependency version replacements . This keeps the dependency versions across each package in sync .