tools/isobuild/builder.js
// root. Throws an exception on failure.
root. Throws an exception on failure.
root . Throws an exception on failure .
_ensureDirectory(relPath) {
    const parts = files.pathNormalize(relPath).split(files.pathSep);
    if (parts.length > 1 && parts[parts.length - 1] === '') {
      parts.pop();
    }
    const partsSoFar = [];
    parts.forEach(part => {
      partsSoFar.push(part);
      const partial = partsSoFar.join(files.pathSep);
      if (! (partial in this.usedAsFile)) {
        let needToMkdir = true;
        if (partial in this.previousUsedAsFile) {
          if (this.previousUsedAsFile[partial]) {
            try {
              files.unlink(partial);
            } catch (e) {
              if (e.code !== "ENOENT") {
                throw e;
              }
            }
          } else {
            needToMkdir = false;
          }
        }
        if (needToMkdir) {
          files.mkdir_p(files.pathJoin(this.buildPath, partial), 0o755);
        }
        this.usedAsFile[partial] = false;
      } else if (this.usedAsFile[partial]) {
        throw new Error(`tried to make ${relPath} a directory but ${partial} is already a file`);
      } else {
      }
    });
  }
_ensureDirectory ( relPath ) { const parts = files . pathNormalize ( relPath ) . split ( files . pathSep ) ; if ( parts . length > 1 && parts [ parts . length - 1 ] === '' ) { parts . pop ( ) ; } const partsSoFar = [ ] ; parts . forEach ( part => { partsSoFar . push ( part ) ; const partial = partsSoFar . join ( files . pathSep ) ; if ( ! ( partial in this . usedAsFile ) ) { let needToMkdir = true ; if ( partial in this . previousUsedAsFile ) { if ( this . previousUsedAsFile [ partial ] ) { try { files . unlink ( partial ) ; } catch ( e ) { if ( e . code !== "ENOENT" ) { throw e ; } } } else { needToMkdir = false ; } } if ( needToMkdir ) { files . mkdir_p ( files . pathJoin ( this . buildPath , partial ) , 0o755 ) ; } this . usedAsFile [ partial ] = false ; } else if ( this . usedAsFile [ partial ] ) { throw new Error ( ` ${ relPath } ${ partial } ` ) ; } else { } } ) ; }
root.
root .
// remove trailing slash // was previously used as file, delete it, create a directory // If files.unlink(partial) failed because the file does not // exist, then we can just pretend the unlink succeeded. // is already a directory // It's new -- create it // Already exists and is a file. Oops. // Already exists and is a directory