MCPcopy Index your code
hub / github.com/SeleniumHQ/selenium / addFile

Method addFile

javascript/selenium-webdriver/io/zip.js:46–60  ·  view source on GitHub ↗

* Adds a file to this zip. * * @param {string} filePath path to the file to add. * @param {string=} zipPath path to the file in the zip archive, defaults * to the basename of `filePath`. * @return {!Promise<?>} a promise that will resolve when added.

(filePath, zipPath = path.basename(filePath))

Source from the content-addressed store, hash-verified

44 * @return {!Promise<?>} a promise that will resolve when added.
45 */
46 addFile(filePath, zipPath = path.basename(filePath)) {
47 let add = Promise.all([io.read(filePath), fs.stat(filePath)]).then(([buffer, stats]) =>
48 this.z_.file(/** @type {string} */ (zipPath.replace(/\\/g, '/')), buffer, {
49 date: stats.mtime, // preserve file's "last modified" value
50 }),
51 )
52 this.pendingAdds_.add(add)
53 return add.then(
54 () => this.pendingAdds_.delete(add),
55 (e) => {
56 this.pendingAdds_.delete(add)
57 throw e
58 },
59 )
60 }
61
62 /**
63 * Recursively adds a directory and all of its contents to this archive.

Callers 3

handleFileMethod · 0.95
addDirMethod · 0.95
zip_test.jsFile · 0.80

Calls 4

fileMethod · 0.80
readMethod · 0.65
addMethod · 0.65
deleteMethod · 0.45

Tested by

no test coverage detected