tools/isobuild/builder.js
// Move the completed bundle into its final location (outputPath)
Move the completed bundle into its final location (outputPath)
Move the completed bundle into its final location ( outputPath )
complete() {
    if (this.previousUsedAsFile) {
      const removed = {};
      const paths = Object.keys(this.previousUsedAsFile);
      paths.forEach((path) => {
        if (this.usedAsFile.hasOwnProperty(path)) { return; }
        if (removed.hasOwnProperty(path)) { return; }
        const absPath = files.pathJoin(this.buildPath, path);
        if (this.previousUsedAsFile[path]) {
          files.unlink(absPath);
          removed[path] = true;
        } else {
          files.rm_recursive(absPath);
          paths.forEach((anotherPath) => {
            if (anotherPath.startsWith(path + '/')) {
              removed[anotherPath] = true;
            }
          });
        }
      });
    }
    if (this.buildPath !== this.outputPath) {
      files.renameDirAlmostAtomically(this.buildPath, this.outputPath);
    }
  }
complete ( ) { if ( this . previousUsedAsFile ) { const removed = { } ; const paths = Object . keys ( this . previousUsedAsFile ) ; paths . forEach ( ( path ) => { if ( this . usedAsFile . hasOwnProperty ( path ) ) { return ; } if ( removed . hasOwnProperty ( path ) ) { return ; } const absPath = files . pathJoin ( this . buildPath , path ) ; if ( this . previousUsedAsFile [ path ] ) { files . unlink ( absPath ) ; removed [ path ] = true ; } else { files . rm_recursive ( absPath ) ; paths . forEach ( ( anotherPath ) => { if ( anotherPath . startsWith ( path + '/' ) ) { removed [ anotherPath ] = true ; } } ) ; } } ) ; } if ( this . buildPath !== this . outputPath ) { files . renameDirAlmostAtomically ( this . buildPath , this . outputPath ) ; } }
Move the completed bundle into its final location (outputPath)
Move the completed bundle into its final location ( outputPath )
// delete files and folders left-over from previous runs and not // re-used in this run // if the same path was re-used, leave it // otherwise, remove it as it is no longer needed // skip if already deleted // file // directory // mark all sub-paths as removed, too // XXX Alternatively, we could just keep buildPath around, and make // outputPath be a symlink pointing to it. This doesn't work for the NPM use // case of renameDirAlmostAtomically since that one is constructing files to // be checked in to version control, but here we could get away with it.