From 0cc9e8abf432e818edd3df1b03278cc259a0fb7e Mon Sep 17 00:00:00 2001 From: exoego Date: Tue, 18 Jun 2019 07:33:17 +0900 Subject: [PATCH] Drop Node.js v6 support since it LTS window ended --- .../main/scala/io/scalajs/nodejs/fs/Fs.scala | 1179 ----------------- .../scala/io/scalajs/nodejs/fs/package.scala | 172 --- .../scala/io/scalajs/nodejs/url/URL.scala | 95 -- .../io/scalajs/nodejs/url/URLObject.scala | 96 -- app/lts/src/test/resources/1.txt | 1 - app/lts/src/test/resources/fileA1.txt | 1 - app/lts/src/test/resources/fileA2.txt | 1 - app/lts/src/test/resources/fileB1.txt | 1 - app/lts/src/test/resources/fileB2.txt | 1 - app/lts/src/test/resources/watchfile.json | 52 - .../io/scalajs/nodejs/fs/FsAsyncTest.scala | 44 - .../scala/io/scalajs/nodejs/fs/FsTest.scala | 77 -- .../io/scalajs/nodejs/url/URLObjectTest.scala | 38 - .../scala/io/scalajs/nodejs/url/URLTest.scala | 39 - build.sbt | 24 +- 15 files changed, 2 insertions(+), 1819 deletions(-) delete mode 100644 app/lts/src/main/scala/io/scalajs/nodejs/fs/Fs.scala delete mode 100644 app/lts/src/main/scala/io/scalajs/nodejs/fs/package.scala delete mode 100644 app/lts/src/main/scala/io/scalajs/nodejs/url/URL.scala delete mode 100644 app/lts/src/main/scala/io/scalajs/nodejs/url/URLObject.scala delete mode 100644 app/lts/src/test/resources/1.txt delete mode 100644 app/lts/src/test/resources/fileA1.txt delete mode 100644 app/lts/src/test/resources/fileA2.txt delete mode 100644 app/lts/src/test/resources/fileB1.txt delete mode 100644 app/lts/src/test/resources/fileB2.txt delete mode 100644 app/lts/src/test/resources/watchfile.json delete mode 100644 app/lts/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala delete mode 100644 app/lts/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala delete mode 100644 app/lts/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala delete mode 100644 app/lts/src/test/scala/io/scalajs/nodejs/url/URLTest.scala diff --git a/app/lts/src/main/scala/io/scalajs/nodejs/fs/Fs.scala b/app/lts/src/main/scala/io/scalajs/nodejs/fs/Fs.scala deleted file mode 100644 index fc5228aae..000000000 --- a/app/lts/src/main/scala/io/scalajs/nodejs/fs/Fs.scala +++ /dev/null @@ -1,1179 +0,0 @@ -package io.scalajs.nodejs -package fs - -import io.scalajs.RawOptions -import io.scalajs.nodejs.buffer.Buffer -import io.scalajs.nodejs.events.IEventEmitter - -import scala.scalajs.js -import scala.scalajs.js.annotation.JSImport -import scala.scalajs.js.typedarray.Uint8Array -import scala.scalajs.js.| - -/** - * File I/O is provided by simple wrappers around standard POSIX functions. To use this module do require('fs'). - * All the methods have asynchronous and synchronous forms. - * - * The asynchronous form always takes a completion callback as its last argument. The arguments passed to the - * completion callback depend on the method, but the first argument is always reserved for an exception. If the - * operation was completed successfully, then the first argument will be null or undefined. - * - * When using the synchronous form any exceptions are immediately thrown. You can use try/catch to handle exceptions - * or allow them to bubble up. - * @author lawrence.daniels@gmail.com - */ -@js.native -trait Fs extends IEventEmitter with FSConstants { - - /** - * Returns an object containing commonly used constants for file system operations - * @return an [[FSConstants object]] containing commonly used constants for file system operations - */ - def constants: FSConstants = js.native - - ///////////////////////////////////////////////////////////////////////////////// - // Methods - ///////////////////////////////////////////////////////////////////////////////// - - /** - * Tests a user's permissions for the file specified by path. mode is an optional integer that specifies - * the accessibility checks to be performed. The following constants define the possible values of mode. - * It is possible to create a mask consisting of the bitwise OR of two or more values. - * - * @param path the path (Buffer | String) - * @param mode the optional mode - * @param callback is a callback function that is invoked with a possible error argument. If any of the accessibility - * checks fail, the error argument will be populated. - * @example fs.access(path[, mode], callback) - */ - def access(path: Buffer | String, mode: FileMode, callback: FsCallback0): Unit = js.native - - /** - * Tests a user's permissions for the file specified by path. mode is an optional integer that specifies - * the accessibility checks to be performed. The following constants define the possible values of mode. - * It is possible to create a mask consisting of the bitwise OR of two or more values. - * - * @param path the path (Buffer | String) - * @param callback is a callback function that is invoked with a possible error argument. If any of the accessibility - * checks fail, the error argument will be populated. - * @example fs.access(path[, mode], callback) - */ - def access(path: Buffer | String, callback: FsCallback0): Unit = js.native - - /** - * Synchronous version of fs.access(). This throws if any accessibility checks fail, and does nothing otherwise. - * @param path the path (Buffer | String) - * @param mode the optional mode - * @example fs.accessSync(path[, mode]) - */ - def accessSync(path: Buffer | String, mode: FileMode = js.native): Unit = js.native - - /** - * Asynchronously append data to a file, creating the file if it does not yet exist. data can be a string or a buffer. - * @param file the filename or file descriptor (Buffer | String | Number) - * @param data the data to append (Buffer | String) - * @param options the [[FileAppendOptions optional append settings]] - * @param callback the callback function - * @example fs.appendFile(file, data[, options], callback) - */ - def appendFile(file: Buffer | FileDescriptor | String, - data: Buffer | String, - options: FileAppendOptions | RawOptions, - callback: FsCallback0): Unit = js.native - - /** - * Asynchronously append data to a file, creating the file if it does not yet exist. data can be a string or a buffer. - * @param file the filename or file descriptor (Buffer | String | Number) - * @param data the data to append (Buffer | String) - * @param callback the callback function - * @example fs.appendFile(file, data[, options], callback) - */ - def appendFile(file: Buffer | FileDescriptor | String, data: Buffer | String, callback: FsCallback0): Unit = js.native - - /** - * The synchronous version of fs.appendFile(). - * @param file the filename or file descriptor (Buffer | String | Number) - * @param data the data to append (Buffer | String) - * @param options the [[FileAppendOptions optional append settings]] - * @return undefined. - */ - def appendFileSync(file: Buffer | FileDescriptor | String, - data: Buffer | String, - options: FileAppendOptions | RawOptions = js.native): Unit = js.native - - /** - * Asynchronous chmod(2). No arguments other than a possible exception are given to the completion callback. - * @param path the file or directory path (Buffer | String) - * @param mode the file or directory mode - * @param callback the completion callback. - */ - def chmod(path: Buffer | String, mode: FileMode, callback: FsCallback0): Unit = js.native - - /** - * Synchronous chmod(2). - * @param path the file or directory path (Buffer | String) - * @param mode the file or directory mode - * @return undefined. - */ - def chmodSync(path: Buffer | String, mode: FileMode): Unit = js.native - - /** - * Asynchronous chown(2). No arguments other than a possible exception are given to the completion callback. - * @param path the file or directory path (Buffer | String) - * @param uid the user ID - * @param gid the group ID - * @param callback the completion callback. - */ - def chown(path: Buffer | String, uid: UID, gid: GID, callback: FsCallback0): Unit = js.native - - /** - * Synchronous chown(2). - * @param path the file or directory path (Buffer | String) - * @param uid the user ID - * @param gid the group ID - * @return undefined. - */ - def chownSync(path: Buffer | String, uid: UID, gid: GID): Unit = js.native - - /** - * Asynchronous close(2). No arguments other than a possible exception are given to the completion callback. - * @example fs.close(fd, callback) - */ - def close(fd: FileDescriptor, callback: FsCallback0): Unit = js.native - - /** - * Synchronous close(2). - * @return undefined. - * @example fs.closeSync(fd) - */ - def closeSync(fd: FileDescriptor): Unit = js.native - - /** - * Asynchronously copies src to dest. By default, dest is overwritten if it already exists. No arguments other - * than a possible exception are given to the callback function. Node.js makes no guarantees about the atomicity - * of the copy operation. If an error occurs after the destination file has been opened for writing, Node.js will - * attempt to remove the destination. - * - * flags is an optional integer that specifies the behavior of the copy operation. The only supported flag is - * fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists. - * @param src the source filename to copy - * @param dest the destination filename of the copy operation - * @param flags the modifiers for copy operation. Default: 0 - * @param callback the callback function - * @example {{{ fs.copyFile(src, dest[, flags], callback) }}} - */ - def copyFile(src: Buffer | String, dest: Buffer | String, flags: Flags, callback: js.Function): Unit = js.native - - /** - * Asynchronously copies src to dest. By default, dest is overwritten if it already exists. No arguments other - * than a possible exception are given to the callback function. Node.js makes no guarantees about the atomicity - * of the copy operation. If an error occurs after the destination file has been opened for writing, Node.js will - * attempt to remove the destination. - * - * flags is an optional integer that specifies the behavior of the copy operation. The only supported flag is - * fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists. - * @param src the source filename to copy - * @param dest the destination filename of the copy operation - * @param callback the callback function - * @example {{{ fs.copyFile(src, dest[, flags], callback) }}} - */ - def copyFile(src: Buffer | String, dest: Buffer | String, callback: js.Function): Unit = js.native - - /** - * Synchronously copies src to dest. By default, dest is overwritten if it already exists. - * - * Node.js makes no guarantees about the atomicity of the copy operation. If an error occurs after the destination - * file has been opened for writing, Node.js will attempt to remove the destination. - * - * flags is an optional integer that specifies the behavior of the copy operation. The only supported flag is - * fs.constants.COPYFILE_EXCL, which causes the copy operation to fail if dest already exists. - * @param src the source filename to copy - * @param dest the destination filename of the copy operation - * @param flags the modifiers for copy operation. Default: 0 - * @example {{{ fs.copyFileSync(src, dest[, flags]) }}} - */ - def copyFileSync(src: Buffer | String, dest: Buffer | String, flags: Flags): Unit = js.native - - /** - * Returns a new ReadStream object. (See Readable Stream). Be aware that, unlike the default value - * set for highWaterMark on a readable stream (16 kb), the stream returned by this method has a - * default value of 64 kb for the same parameter. - * @param path the path (Buffer | String) - * @param options the optional stream options - * @example fs.createReadStream(path[, options]) - */ - def createReadStream(path: Buffer | String, options: FileInputOptions | RawOptions = js.native): ReadStream = - js.native - - /** - * Returns a new WriteStream object. - * @param path the path (Buffer | String) - * @param options the optional stream options - * @example fs.createWriteStream(path[, options]) - */ - def createWriteStream(path: Buffer | String, options: FileOutputOptions | RawOptions = js.native): WriteStream = - js.native - - /** - * Test whether or not the given path exists by checking with the file system. Then call the callback argument with - * either true or false. - * @example fs.exists('/etc/passwd', (exists) => { ... }) - */ - @deprecated("Use fs.stat() or fs.access() instead.", since = "1.0.0") - def exists(path: Buffer | String, callback: js.Function1[Boolean, Any]): Unit = js.native - - /** - * fs.exists() should not be used to check if a file exists before calling fs.open(). Doing so introduces a race - * condition since other processes may change the file's state between the two calls. Instead, user code should - * call fs.open() directly and handle the error raised if the file is non-existent. - * @example fs.existsSync(path) - */ - def existsSync(path: Buffer | String): Boolean = js.native - - /** - * Asynchronous fchmod(2). No arguments other than a possible exception are given to the completion callback. - * @example fs.fchmod(fd, mode, callback) - */ - def fchmod(fd: FileDescriptor, mode: FileMode, callback: FsCallback0): Unit = js.native - - /** - * Synchronous fchmod(2). - * @return undefined. - * @example fs.fchmodSync(fd, mode) - */ - def fchmodSync(fd: FileDescriptor, mode: FileMode): Unit = js.native - - /** - * Asynchronous fchown(2). No arguments other than a possible exception are given to the completion callback. - * @param path the file or directory path (Buffer | String) - * @param uid the user ID - * @param gid the group ID - * @param callback the completion callback. - */ - def fchown(path: Buffer | String, uid: UID, gid: GID, callback: FsCallback0): Unit = js.native - - /** - * Synchronous fchown(2). - * @param path the file or directory path (Buffer | String) - * @param uid the user ID - * @param gid the group ID - * @return undefined. - * - */ - def fchownSync(path: Buffer | String, uid: UID, gid: GID): Unit = js.native - - /** - * Asynchronous fdatasync(2). No arguments other than a possible exception are given to the completion callback. - * @example fs.fdatasync(fd, callback) - */ - def fdatasync(fd: FileDescriptor, callback: FsCallback0): Unit = js.native - - /** - * Synchronous fdatasync(2). - * @return undefined. - * @example fs.fdatasyncSync(fd) - */ - def fdatasyncSync(fd: FileDescriptor): Unit = js.native - - /** - * Asynchronous fstat(2). The callback gets two arguments (err, stats) where stats is an fs.Stats object. - * fstat() is identical to stat(), except that the file to be stat-ed is specified by the file descriptor fd. - * @param fd the file descriptor - * @param callback the completion callback. - */ - def fstat(fd: FileDescriptor, callback: FsCallback1[Stats]): Unit = js.native - - /** - * Synchronous fstat(2). - * @param fd the file descriptor - * @return an instance of [[fs.Stats]]. - */ - def fstatSync(fd: FileDescriptor): Stats = js.native - - /** - * Asynchronous fsync(2). No arguments other than a possible exception are given to the completion callback. - * @param fd the file descriptor - * @param callback the completion callback. - */ - def fsync(fd: FileDescriptor, callback: FsCallback0): Unit = js.native - - /** - * Synchronous fsync(2). - * @return undefined. - * @param fd the file descriptor - */ - def fsyncSync(fd: FileDescriptor): Unit = js.native - - /** - * Asynchronous ftruncate(2). No arguments other than a possible exception are given to the completion callback. - * If the file referred to by the file descriptor was larger than length bytes, only the first length bytes will be - * retained in the file. - * @param fd the file descriptor - * @param length the desired length - * @param callback the completion callback. - */ - def ftruncate(fd: FileDescriptor, length: Double, callback: FsCallback0): Unit = js.native - - /** - * Synchronous ftruncate(2). - * @param fd the file descriptor - * @param length the desired length - * @return undefined. - */ - def ftruncateSync(fd: FileDescriptor, length: Double): Unit = js.native - - /** - * Change the file timestamps of a file referenced by the supplied file descriptor. - * @example fs.futimes(fd, atime, mtime, callback) - */ - def futimes(fd: FileDescriptor, atime: Integer, mtime: Integer, callback: js.Function): Unit = js.native - - /** - * Synchronous version of fs.futimes(). - * @return undefined. - * @example fs.futimesSync(fd, atime, mtime) - */ - def futimesSync(fd: FileDescriptor, atime: Integer, mtime: Integer): Unit = js.native - - /** - * Asynchronous lchmod(2). No arguments other than a possible exception are given to the completion callback. - * @example fs.lchmod(path, mode, callback) - */ - def lchmod(path: Buffer | String, mode: FileMode, callback: FsCallback0): Unit = js.native - - /** - * Synchronous lchmod(2). - * @param path the path (Buffer | String) - * @param mode the mode (Integer) - * @return undefined. - * @example fs.lchmodSync(path, mode) - */ - def lchmodSync(path: Buffer | String, mode: FileMode): Unit = js.native - - /** - * Asynchronous lchown(2). No arguments other than a possible exception are given to the completion callback. - * @param path the path (Buffer | String) - * @param uid the user ID - * @param gid the group ID - * @param callback the completion callback. - * @example fs.lchown(path, uid, gid, callback) - */ - def lchown(path: Buffer | String, uid: UID, gid: GID, callback: FsCallback0): Unit = js.native - - /** - * Synchronous chown(2). - * @param path the path (Buffer | String) - * @param uid the user ID - * @param gid the group ID - * @return undefined. - */ - def lchownSync(path: Buffer | String, uid: UID, gid: GID): Unit = js.native - - /** - * Asynchronous link(2). No arguments other than a possible exception are given to the completion callback. - * @param existingPath the existing path - * @param newPath the new path - * @param callback the completion callback. - * @example fs.link(srcpath, dstpath, callback) - */ - def link(existingPath: Buffer | String, newPath: Buffer | String, callback: FsCallback0): Unit = js.native - - /** - * Synchronous link(2). - * @param existingPath the existing path - * @param newPath the new path - * @return undefined. - */ - def linkSync(existingPath: Buffer | String, newPath: Buffer | String): Unit = js.native - - /** - * Asynchronous lstat(2). - * lstat() is identical to stat(), except that if path is a symbolic link, then the link itself is stat-ed, - * not the file that it refers to. - * @param path the path (Buffer | String) - * @param callback The callback gets two arguments (err, stats) where stats is a fs.Stats object. - */ - def lstat(path: Buffer | String, callback: FsCallback1[Stats]): Unit = js.native - - /** - * Synchronous lstat(2). - * @param path the path (Buffer | String) - * @return an instance of [[fs.Stats]]. - */ - def lstatSync(path: Buffer | String): Stats = js.native - - /** - * Asynchronous mkdir(2). No arguments other than a possible exception are given to the completion callback. - * mode defaults to 0o777. - * @example fs.mkdir(path[, mode], callback) - */ - def mkdir(path: Buffer | String, mode: FileMode, callback: FsCallback0): Unit = js.native - - /** - * Asynchronous mkdir(2). No arguments other than a possible exception are given to the completion callback. - * mode defaults to 0o777. - * @example fs.mkdir(path[, mode], callback) - */ - def mkdir(path: Buffer | String, callback: FsCallback0): Unit = js.native - - /** - * Synchronous mkdir(2). - * @param path the path - * @param mode the mode - */ - def mkdirSync(path: Buffer | String, mode: FileMode = js.native): Unit = js.native - - /** - * Creates a unique temporary directory. - * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. - * The created folder path is passed as a string to the callback's second parameter. - * The optional options argument can be a string specifying an encoding, or an object with an - * encoding property specifying the character encoding to use. - * @param prefix the prefix - * @param options the optional encoding setting - * @param callback the callback - * @example fs.mkdtemp(prefix[, options], callback) - */ - def mkdtemp(prefix: String, options: String | FileEncodingOptions | RawOptions, callback: FsCallback1[String]): Unit = - js.native - - /** - * Creates a unique temporary directory. - * Generates six random characters to be appended behind a required prefix to create a unique temporary directory. - * The created folder path is passed as a string to the callback's second parameter. - * The optional options argument can be a string specifying an encoding, or an object with an - * encoding property specifying the character encoding to use. - * @param prefix the prefix - * @param callback the callback - * @example fs.mkdtemp(prefix[, options], callback) - */ - def mkdtemp(prefix: String, callback: FsCallback1[String]): Unit = js.native - - /** - * The synchronous version of fs.mkdtemp(). Returns the created folder path. - * The optional options argument can be a string specifying an encoding, or an object with - * an encoding property specifying the character encoding to use. - * @param prefix the prefix - * @param options the optional encoding setting - */ - def mkdtempSync(prefix: String, options: String | FileEncodingOptions | RawOptions = js.native): String = js.native - - /** - * Asynchronous file open. See open(2). - * @param path the path (Buffer | String) - * @param flags flags can be: - * - * @param mode sets the file mode (permission and sticky bits), but only if the file was created. - * It defaults to 0666, readable and writable. - * @param callback the callback gets two arguments (err, fd) - * @example fs.open(path, flags[, mode], callback) - */ - def open(path: Buffer | String, flags: Flags, mode: FileMode, callback: FsCallback1[FileDescriptor]): Unit = js.native - - /** - * Asynchronous file open. See open(2). - * @param path the path (Buffer | String) - * @param flags flags can be: - * - * @param callback the callback gets two arguments (err, fd) - * @example fs.open(path, flags[, mode], callback) - */ - def open(path: Buffer | String, flags: Flags, callback: FsCallback1[FileDescriptor]): Unit = js.native - - /** - * Synchronous version of fs.open(). - * @param path the path (Buffer | String) - * @param flags the flags - * @param mode the file mode - * @return an integer representing the file descriptor. - * @example fs.openSync(path, flags[, mode]) - */ - def openSync(path: Buffer | String, flags: Flags, mode: FileMode = js.native): FileDescriptor = js.native - - /** - * Read data from the file specified by fd. - * @param fd is the file descriptor - * @param buffer is the buffer that the data will be written to. - * @param offset is the offset in the buffer to start writing at. - * @param length is an integer specifying the number of bytes to read. - * @param position is an integer specifying where to begin reading from in the file. If position is null, - * data will be read from the current file position. - * @param callback the callback is given the three arguments, (err, bytesRead, buffer). - */ - def read(fd: FileDescriptor, - buffer: Buffer, - offset: Int, - length: Int, - position: Int, - callback: FsCallback2[Int, Buffer]): Unit = js.native - - /** - * Synchronous version of fs.read(). - * @param fd is the file descriptor - * @param buffer is the buffer that the data will be written to. - * @param offset is the offset in the buffer to start writing at. - * @param length is an integer specifying the number of bytes to read. - * @param position is an integer specifying where to begin reading from in the file. If position is null, - * data will be read from the current file position. - * @return the number of bytesRead. - */ - def readSync(fd: FileDescriptor, buffer: Buffer, offset: Int, length: Int, position: Int): Int = js.native - - /** - * Asynchronous readdir(3). Reads the contents of a directory. - * @param path the path (Buffer | String) - * @param options the optional options argument can be a string specifying an encoding, - * or an object with an encoding property specifying the character encoding - * to use for the filenames passed to the callback. If the encoding is set - * to 'buffer', the filenames returned will be passed as Buffer objects. - * @param callback the callback gets two arguments (err, files) where files is an array - * of the names of the files in the directory excluding '.' and '..'. - * @example fs.readdir(path[, options], callback) - */ - def readdir(path: Buffer | String, - options: String | FileEncodingOptions | RawOptions, - callback: FsCallback1[js.Array[String]]): Unit = js.native - - /** - * Asynchronous readdir(3). Reads the contents of a directory. - * @param path the path (Buffer | String) - * @param callback the callback gets two arguments (err, files) where files is an array - * of the names of the files in the directory excluding '.' and '..'. - * @example fs.readdir(path[, options], callback) - */ - def readdir(path: Buffer | String, callback: FsCallback1[js.Array[String]]): Unit = js.native - - /** - * Synchronous readdir(3). - * @param path the path (Buffer | String) - * @param options the optional options argument can be a string specifying an encoding, - * or an object with an encoding property specifying the character encoding - * to use for the filenames passed to the callback. If the encoding is set - * to 'buffer', the filenames returned will be passed as Buffer objects. - * @return an array of filenames excluding '.' and '..'. - */ - def readdirSync(path: Buffer | String, - options: String | FileEncodingOptions | RawOptions = js.native): js.Array[String] = js.native - - /** - * Asynchronously reads the entire contents of a file. - * @param file filename or file descriptor - * @param options the optional settings - * @param callback The callback is passed two arguments (err, data), where data is the contents of the file. - * If no encoding is specified, then the raw buffer is returned. - * @example fs.readFile(file[, options], callback) - */ - def readFile(file: Buffer | FileDescriptor | String, - options: String | FileInputOptions | RawOptions | String, - callback: FsCallback1[js.Any]): Unit = js.native - - /** - * Asynchronously reads the entire contents of a file. - * @param file filename or file descriptor - * @param encoding the encoding (default = null) - * @param callback The callback is passed two arguments (err, data), where data is the contents of the file. - * If no encoding is specified, then the raw buffer is returned. - * @example fs.readFile(file[, options], callback) - */ - def readFile(file: Buffer | FileDescriptor | String, encoding: String, callback: FsCallback1[String]): Unit = - js.native - - /** - * Asynchronously reads the entire contents of a file. - * @param file filename or file descriptor - * @param callback The callback is passed two arguments (err, data), where data is the contents of the file. - * If no encoding is specified, then the raw buffer is returned. - * @example fs.readFile(file[, options], callback) - */ - def readFile(file: Buffer | FileDescriptor | String, callback: FsCallback1[Buffer]): Unit = js.native - - /** - * Synchronous version of fs.readFile. Returns the contents of the file. - * @param file filename or file descriptor | | - * @param encoding the optional encoding | - * @return the contents of the file. If the encoding option is specified then this function returns a string. - * Otherwise it returns a buffer. - * @example fs.readFileSync(file[, options]) - */ - def readFileSync(file: Buffer | FileDescriptor | String, encoding: String): String = js.native - - /** - * Synchronous version of fs.readFile. Returns the contents of the file. - * @param file filename or file descriptor | | - * @param options the optional encoding | - * @return the contents of the file. If the encoding option is specified then this function returns a string. - * Otherwise it returns a buffer. - * @example fs.readFileSync(file[, options]) - */ - def readFileSync(file: Buffer | FileDescriptor | String, options: FileInputOptions | RawOptions = js.native): js.Any = - js.native - - /** - * Synchronous version of fs.readFile. - * @param file filename or file descriptor | | - * @return the contents of the file. If the encoding option is specified then this function returns a string. - * Otherwise it returns a buffer. - * @example fs.readFileSync(file[, options]) - */ - def readFileSync(file: Buffer | FileDescriptor | String): Buffer = js.native - - /** - * Asynchronous readlink(2). - * If the encoding is set to 'buffer', the link path returned will be passed as a Buffer object. - * @param path the path (Buffer | String) - * @param options the optional options argument can be a string specifying an encoding, or an object - * with an encoding property specifying the character encoding to use for the link path - * passed to the callback. - * @param callback the callback gets two arguments (err, linkString). - * @example fs.readlink(path[, options], callback) - */ - def readlink(path: Buffer | String, - options: String | FileEncodingOptions | RawOptions, - callback: FsCallback1[String]): Unit = js.native - - /** - * Synchronous readlink(2). - * @param path the path (Buffer | String) - * @param options the optional options argument can be a string specifying an encoding, - * or an object with an encoding property specifying the character encoding - * to use for the link path passed to the callback. If the encoding is set - * to 'buffer', the link path returned will be passed as a Buffer object. - * @return the symbolic link's string value. - */ - def readlinkSync(path: Buffer | String, options: String | FileEncodingOptions | RawOptions = js.native): String = - js.native - - /** - * Asynchronous realpath(2). - * May use process.cwd to resolve relative paths. - * @param path the path - * @param options The optional options argument can be a string specifying an encoding, or an object with - * an encoding property specifying the character encoding to use for the path passed to the callback. - * @param callback The callback gets two arguments (err, resolvedPath). - * If the encoding is set to 'buffer', - * the path returned will be passed as a Buffer object. - * @example fs.realpath(path[, options], callback) - */ - def realpath(path: Buffer | String, - options: FileEncodingOptions | String | RawOptions, - callback: FsCallback1[String]): Unit = js.native - - /** - * Asynchronous realpath(2). The callback gets two arguments (err, resolvedPath). - * May use process.cwd to resolve relative paths. - * - * The optional options argument can be a string specifying an encoding, or an object with an encoding property - * specifying the character encoding to use for the path passed to the callback. If the encoding is set to 'buffer', - * the path returned will be passed as a Buffer object. - * @example fs.realpath(path[, options], callback) - */ - def realpath(path: Buffer | String, callback: FsCallback1[String]): Unit = js.native - - /** - * Synchronous realpath(3). - * Only paths that can be converted to UTF8 strings are supported. - * The optional options argument can be a string specifying an encoding, or an object with an - * encoding property specifying the character encoding to use for the returned value. If the - * encoding is set to 'buffer', the path returned will be passed as a Buffer object. - * @return the resolved path. - * @example fs.realpathSync(path[, options]) - */ - def realpathSync(path: Buffer | String, options: FileEncodingOptions | String | RawOptions = js.native): String = - js.native - - /** - * Asynchronous rename(2). No arguments other than a possible exception are given to the completion callback. - * @example fs.rename(oldPath, newPath, callback) - */ - def rename(oldPath: Buffer | String, newPath: Buffer | String, callback: FsCallback0): Unit = js.native - - /** - * Synchronous rename(2). - * @return undefined. - * @example fs.renameSync(oldPath, newPath) - */ - def renameSync(oldPath: Buffer | String, newPath: Buffer | String): Unit = js.native - - /** - * Asynchronous rmdir(2). No arguments other than a possible exception are given to the completion callback. - * @example fs.rmdir(path, callback) - */ - def rmdir(path: Buffer | String, callback: FsCallback0): Unit = js.native - - /** - * Synchronous rmdir(2). - * @return undefined. - * @example fs.rmdirSync(path) - */ - def rmdirSync(path: Buffer | String): Unit = js.native - - /** - * Asynchronous stat(2). The callback gets two arguments (err, stats) where stats is a [[fs.Stats]] object. - * See the fs.Stats section for more information. - * @example fs.stat(path, callback) - */ - def stat(path: Buffer | String, callback: FsCallback1[Stats]): Stats = js.native - - /** - * Synchronous stat(2). Returns an instance of [[fs.Stats]]. - * @example fs.statSync(path) - */ - def statSync(path: Buffer | String): Stats = js.native - - /** - * Asynchronous symlink(2). No arguments other than a possible exception are given to the completion callback. - * The type argument can be set to 'dir', 'file', or 'junction' (default is 'file') and is only available on Windows - * (ignored on other platforms). Note that Windows junction points require the destination path to be absolute. - * When using 'junction', the target argument will automatically be normalized to absolute path. - * @example fs.symlink(target, path[, type], callback) - */ - def symlink(target: Buffer | String, path: Buffer | String, `type`: String, callback: FsCallback0): Unit = js.native - - /** - * Asynchronous symlink(2). No arguments other than a possible exception are given to the completion callback. - * The type argument can be set to 'dir', 'file', or 'junction' (default is 'file') and is only available on Windows - * (ignored on other platforms). Note that Windows junction points require the destination path to be absolute. - * When using 'junction', the target argument will automatically be normalized to absolute path. - * @example fs.symlink(target, path[, type], callback) - */ - def symlink(target: Buffer | String, path: Buffer | String, callback: FsCallback0): Unit = js.native - - /** - * Synchronous symlink(2). - * @return undefined. - * @example fs.symlinkSync(target, path[, type]) - */ - def symlinkSync(target: Buffer | String, path: Buffer | String, `type`: String = js.native): Unit = js.native - - /** - * Asynchronous truncate(2). No arguments other than a possible exception are given to the completion callback. - * A file descriptor can also be passed as the first argument. In this case, fs.ftruncate() is called. - * @param path the path | - * @param length the length - * @param callback the completion callback. - * @example fs.truncate(path, length, callback) - */ - def truncate(path: Buffer | FileDescriptor | String, length: Int, callback: FsCallback0): Unit = js.native - - /** - * Synchronous truncate(2). - * In this case, fs.ftruncateSync() is called. - * @param path the path or file descriptor - | | - * @param length the length - * @return undefined. - * @example fs.truncateSync(path, length) - */ - def truncateSync(path: Buffer | FileDescriptor | String, length: Int): Unit = js.native - - /** - * Asynchronous unlink(2). No arguments other than a possible exception are given to the completion callback. - * @example fs.unlink(path, callback) - */ - def unlink(path: Buffer | String, callback: FsCallback0): Unit = js.native - - /** - * Synchronous unlink(2). - * @return undefined. - * @example fs.unlinkSync(path) - */ - def unlinkSync(path: Buffer | String): Unit = js.native - - /** - * Stop watching for changes on filename. If listener is specified, only that particular listener is removed. - * Otherwise, all listeners are removed and you have effectively stopped watching filename. - * - * Calling fs.unwatchFile() with a filename that is not being watched is a no-op, not an error. - * - * Note: fs.watch() is more efficient than fs.watchFile() and fs.unwatchFile(). fs.watch() should be used instead of - * fs.watchFile() and fs.unwatchFile() when possible. - * @example fs.unwatchFile(filename[, listener]) - */ - def unwatchFile(filename: Buffer | String, listener: FsCallback0 = js.native): Unit = js.native - - /** - * Change file timestamps of the file referenced by the supplied path. - * - * Note: the arguments atime and mtime of the following related functions does follow the below rules: - * - * If the value is a numberable string like '123456789', the value would get converted to corresponding number. - * If the value is NaN or Infinity, the value would get converted to Date.now(). - * @example fs.utimes(path, atime, mtime, callback) - */ - def utimes(path: Buffer | String, atime: Int, mtime: Int, callback: FsCallback0): Unit = js.native - - /** - * Synchronous version of fs.utimes(). - * @return undefined. - * @example fs.utimesSync(path, atime, mtime) - */ - def utimesSync(path: Buffer | String, atime: Int, mtime: Int): Unit = js.native - - /** - * Watch for changes on filename, where filename is either a file or a directory. - * The returned object is a [[fs.FSWatcher]]. - * - * The second argument is optional. If options is provided as a string, it specifies the encoding. - * Otherwise options should be passed as an object. - * - * The listener callback gets two arguments (event, filename). event is either 'rename' or 'change', and filename - * is the name of the file which triggered the event. - * @param filename the filename (Buffer | String) - * @param options the [[FSWatcherOptions optional settings]] - * @param listener the callback function - * @return a [[FSWatcher]] - * @example fs.watch(filename[, options][, listener]) - */ - def watch(filename: Buffer | String, - options: FSWatcherOptions | RawOptions, - listener: js.Function2[EventType, String, Any]): FSWatcher = js.native - - /** - * Watch for changes on filename, where filename is either a file or a directory. - * The returned object is a [[fs.FSWatcher]]. - * - * The second argument is optional. If options is provided as a string, it specifies the encoding. - * Otherwise options should be passed as an object. - * - * The listener callback gets two arguments (event, filename). event is either 'rename' or 'change', and filename - * is the name of the file which triggered the event. - * @param filename the filename (Buffer | String) - * @param listener the listener callback gets two arguments (eventType, filename). - * eventType is either 'rename' or 'change', - * and filename is the name of the file which triggered the event. - * @return a [[FSWatcher]] - * @example fs.watch(filename[, options][, listener]) - */ - def watch(filename: Buffer | String, listener: js.Function2[EventType, String, Any]): FSWatcher = js.native - - /** - * Watch for changes on filename, where filename is either a file or a directory. - * The returned object is a [[fs.FSWatcher]]. - * - * The second argument is optional. If options is provided as a string, it specifies the encoding. - * Otherwise options should be passed as an object. - * - * The listener callback gets two arguments (event, filename). event is either 'rename' or 'change', and filename - * is the name of the file which triggered the event. - * @param filename the filename (Buffer | String) - * @param options the [[FSWatcherOptions optional settings]] - * @return a [[FSWatcher]] - * @example fs.watch(filename[, options][, listener]) - */ - def watch(filename: Buffer | String, options: FSWatcherOptions | RawOptions = js.native): FSWatcher = js.native - - /** - * Watch for changes on filename. The callback listener will be called each time the file is accessed. - * - * The options argument may be omitted. If provided, it should be an object. The options object may contain - * a boolean named persistent that indicates whether the process should continue to run as long as files are - * being watched. The options object may specify an interval property indicating how often the target should - * be polled in milliseconds. The default is { persistent: true, interval: 5007 }. - * @param filename the filename (Buffer | String) - * @param options the [[FSWatcherOptions optional settings]] - * @param listener the callback - */ - def watchFile(filename: Buffer | String, - options: FileWatcherOptions | RawOptions, - listener: FsCallback2[Stats, Stats]): Unit = js.native - - /** - * Watch for changes on filename. The callback listener will be called each time the file is accessed. - * - * The options argument may be omitted. If provided, it should be an object. The options object may contain - * a boolean named persistent that indicates whether the process should continue to run as long as files are - * being watched. The options object may specify an interval property indicating how often the target should - * be polled in milliseconds. The default is { persistent: true, interval: 5007 }. - * @param filename the filename (Buffer | String) - * @param listener the callback - */ - def watchFile(filename: Buffer | String, listener: FsCallback2[Stats, Stats]): Unit = js.native - - /** - * Write buffer to the file specified by fd. - *

Note: that it is unsafe to use fs.write multiple times on the same file without waiting for the callback. - * For this scenario, fs.createWriteStream is strongly recommended.

- *

On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the - * position argument and always appends the data to the end of the file.

- * @param fd the file descriptor - * @param buffer the buffer containing the data to write - * @param offset determines the part of the buffer to be written, and length is an integer specifying - * the number of bytes to write. - * @param length the optional length of the data to write - * @param position refers to the offset from the beginning of the file where this data should be written. - * If typeof position !== 'number', the data will be written at the current position. See pwrite(2). - * @param callback will be given three arguments (err, written, buffer) where written specifies how many - * bytes were written from buffer. - * @example {{{ fs.write(fd, buffer[, offset[, length[, position]]], callback) }}} - **/ - def write(fd: FileDescriptor, - buffer: Buffer | Uint8Array, - offset: Integer = js.native, - length: Integer = js.native, - position: Integer = js.native, - callback: FsCallback2[Int, Buffer]): Unit = js.native - - /** - * Write buffer to the file specified by fd. - *

Note: that it is unsafe to use fs.write multiple times on the same file without waiting for the callback. - * For this scenario, fs.createWriteStream is strongly recommended.

- *

On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the - * position argument and always appends the data to the end of the file.

- * @param fd the file descriptor - * @param buffer the buffer containing the data to write - * If typeof position !== 'number', the data will be written at the current position. See pwrite(2). - * @param callback will be given three arguments (err, written, buffer) where written specifies how many - * bytes were written from buffer. - * @example {{{ fs.write(fd, buffer[, offset[, length[, position]]], callback) }}} - **/ - def write(fd: FileDescriptor, buffer: Buffer | Uint8Array, callback: FsCallback2[Int, Buffer]): Unit = js.native - - /** - * Write string to the file specified by fd. If string is not a string, then the value will be coerced to one. - * Unlike when writing buffer, the entire string must be written. No substring may be specified. - * This is because the byte offset of the resulting data may not be the same as the string offset. - * Note that it is unsafe to use fs.write multiple times on the same file without waiting for the callback. - * For this scenario, fs.createWriteStream is strongly recommended. - * On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the - * position argument and always appends the data to the end of the file. - * @param fd the file descriptor - * @param string the data to write - * @param position refers to the offset from the beginning of the file where this data should be written. - * If typeof position !== 'number' the data will be written at the current position. See pwrite(2). - * @param encoding is the expected string encoding. - * @param callback will receive the arguments (err, written, string) where written specifies how many bytes - * the passed string required to be written. Note that bytes written is not the same as - * string characters. See Buffer.byteLength. - * @example {{{ fs.write(fd, string[, position[, encoding]], callback) }}} - */ - def write(fd: FileDescriptor, - string: String, - position: Int, - encoding: String, - callback: FsCallback2[Int, String]): Unit = js.native - - /** - * Write string to the file specified by fd. If string is not a string, then the value will be coerced to one. - * Unlike when writing buffer, the entire string must be written. No substring may be specified. - * This is because the byte offset of the resulting data may not be the same as the string offset. - * Note that it is unsafe to use fs.write multiple times on the same file without waiting for the callback. - * For this scenario, fs.createWriteStream is strongly recommended. - * On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the - * position argument and always appends the data to the end of the file. - * @param fd the file descriptor - * @param string the data to write - * @param encoding is the expected string encoding. - * @param callback will receive the arguments (err, written, string) where written specifies how many bytes - * the passed string required to be written. Note that bytes written is not the same as - * string characters. See Buffer.byteLength. - * @example {{{ fs.write(fd, string[, position[, encoding]], callback) }}} - */ - def write(fd: FileDescriptor, string: String, encoding: String, callback: FsCallback2[Int, String]): Unit = js.native - - /** - * Write string to the file specified by fd. If string is not a string, then the value will be coerced to one. - * Unlike when writing buffer, the entire string must be written. No substring may be specified. - * This is because the byte offset of the resulting data may not be the same as the string offset. - * Note that it is unsafe to use fs.write multiple times on the same file without waiting for the callback. - * For this scenario, fs.createWriteStream is strongly recommended. - * On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the - * position argument and always appends the data to the end of the file. - * @param fd the file descriptor - * @param string the data to write - * @param callback will receive the arguments (err, written, string) where written specifies how many bytes - * the passed string required to be written. Note that bytes written is not the same as - * string characters. See Buffer.byteLength. - * @example {{{ fs.write(fd, string[, position[, encoding]], callback) }}} - */ - def write(fd: FileDescriptor, string: String, callback: FsCallback2[Int, String]): Unit = js.native - - /** - * Asynchronously writes data to a file, replacing the file if it already exists. data can be a string or a buffer. - * The encoding option is ignored if data is a buffer. It defaults to 'utf8' - * @example fs.writeFile(file, data[, options], callback) - */ - def writeFile(file: String, - data: Buffer | String, - options: FileOutputOptions | RawOptions, - callback: FsCallback0): Unit = js.native - - /** - * Asynchronously writes data to a file, replacing the file if it already exists. data can be a string or a buffer. - * The encoding option is ignored if data is a buffer. It defaults to 'utf8' - * @example fs.writeFile(file, data[, options], callback) - */ - def writeFile(file: String, data: Buffer | String, callback: FsCallback0): Unit = js.native - - /** - * The synchronous version of fs.writeFile(). - * @return undefined. - * @example fs.writeFileSync(file, data[, options]) - */ - def writeFileSync(file: String, data: Buffer | String, options: FileOutputOptions | RawOptions = js.native): Unit = - js.native - - /** - * Write buffer to the file specified by fd. - * @param fd the given file descriptor - * @param buffer the given [[Buffer buffer]] - * @param offset determines the part of the buffer to be written, and length is an integer specifying - * the number of bytes to write. - * @param length the optional length of the data to write - * @param position refers to the offset from the beginning of the file where this data should be written. - * @example {{{ fs.writeSync(fd, buffer[, offset[, length[, position]]]) }}} - */ - def writeSync(fd: FileDescriptor, - buffer: Buffer | Uint8Array, - offset: Int = js.native, - length: Int = js.native, - position: Int = js.native): Unit = js.native - - /** - * Write buffer to the file specified by fd. - * @param fd the given file descriptor - * @param buffer the given [[Buffer buffer]] - * @example {{{ fs.writeSync(fd, buffer[, offset[, length[, position]]]) }}} - */ - def writeSync(fd: FileDescriptor, buffer: Buffer | Uint8Array): Unit = js.native - - /** - * Write string to the file specified by fd. - * @param fd the given file descriptor - * @param data the given string - * @param position refers to the offset from the beginning of the file where this data should be written. - * @param encoding is the expected string encoding. - * @example {{{ fs.writeSync(fd, string[, position[, encoding]]) }}} - */ - def writeSync(fd: FileDescriptor, data: String, position: Int, encoding: String): Unit = js.native - - /** - * Write string to the file specified by fd. - * @param fd the given file descriptor - * @param data the given string - * @param position refers to the offset from the beginning of the file where this data should be written. - * @example {{{ fs.writeSync(fd, string[, position[, encoding]]) }}} - */ - def writeSync(fd: FileDescriptor, data: String, position: Int): Unit = js.native - - /** - * Write string to the file specified by fd. - * @param fd the given file descriptor - * @param data the given string - * @param encoding is the expected string encoding. - * @example {{{ fs.writeSync(fd, string[, position[, encoding]]) }}} - */ - def writeSync(fd: FileDescriptor, data: String, encoding: String): Unit = js.native - - /** - * Write string to the file specified by fd. - * @param fd the given file descriptor - * @param data the given string - * @example {{{ fs.writeSync(fd, string[, position[, encoding]]) }}} - */ - def writeSync(fd: FileDescriptor, data: String): Unit = js.native - -} - -/** - * File System Singleton - * @author lawrence.daniels@gmail.com - */ -@js.native -@JSImport("fs", JSImport.Namespace) -object Fs extends Fs - -/** - * File Append Options - * @author lawrence.daniels@gmail.com - */ -class FileAppendOptions(val encoding: js.UndefOr[String] = js.undefined, - val mode: js.UndefOr[FileMode] = js.undefined, - val flag: js.UndefOr[String] = js.undefined) - extends js.Object - -/** - * File Encoding Options - * @author lawrence.daniels@gmail.com - */ -class FileEncodingOptions(val encoding: js.UndefOr[String] = js.undefined) extends js.Object - -/** - * File Input Options - * @author lawrence.daniels@gmail.com - */ -class FileInputOptions(val flags: js.UndefOr[String] = js.undefined, - val encoding: js.UndefOr[String] = js.undefined, - val fd: js.UndefOr[FileDescriptor] = js.undefined, - val mode: js.UndefOr[Int] = js.undefined, - val autoClose: js.UndefOr[Boolean] = js.undefined, - val start: js.UndefOr[Int] = js.undefined, - val end: js.UndefOr[Int] = js.undefined) - extends js.Object - -/** - * File Input Options - * @author lawrence.daniels@gmail.com - */ -class FileOutputOptions(val flags: js.UndefOr[String] = js.undefined, - val defaultEncoding: js.UndefOr[String] = js.undefined, - val fd: js.UndefOr[FileDescriptor] = js.undefined, - val mode: js.UndefOr[Int] = js.undefined, - val autoClose: js.UndefOr[Boolean] = js.undefined, - val start: js.UndefOr[Int] = js.undefined) - extends js.Object - -/** - * File Watcher Options - * @param persistent - * @param interval - */ -class FileWatcherOptions(val persistent: js.UndefOr[Boolean] = js.undefined, - val interval: js.UndefOr[Int] = js.undefined) - extends js.Object diff --git a/app/lts/src/main/scala/io/scalajs/nodejs/fs/package.scala b/app/lts/src/main/scala/io/scalajs/nodejs/fs/package.scala deleted file mode 100644 index 37ea73115..000000000 --- a/app/lts/src/main/scala/io/scalajs/nodejs/fs/package.scala +++ /dev/null @@ -1,172 +0,0 @@ -package io.scalajs.nodejs - -import io.scalajs.RawOptions -import io.scalajs.nodejs.buffer.Buffer -import io.scalajs.util.PromiseHelper._ - -import scala.concurrent.Future -import scala.scalajs.js -import scala.scalajs.js.typedarray.Uint8Array -import scala.scalajs.js.| - -/** - * fs package object - * @author lawrence.daniels@gmail.com - */ -package object fs { - - ///////////////////////////////////////////////////////////////////////////////// - // Implicit conversions and classes - ///////////////////////////////////////////////////////////////////////////////// - - /** - * File System Extensions - * @param fs the given [[Fs file system]] instance - */ - final implicit class FsExtensions(val fs: Fs) extends AnyVal { - - @inline - def accessFuture(path: Buffer | String, mode: FileMode = null): Future[Unit] = { - promiseWithError0[FileIOError](fs.access(path, mode, _)) - } - - @inline - def appendFileFuture(file: Buffer | FileDescriptor | String, - data: Buffer | String, - options: FileAppendOptions = null): Future[Unit] = { - promiseWithError0[FileIOError](fs.appendFile(file, data, options, _)) - } - - @inline - def chmodFuture(path: Buffer | String, mode: FileMode, callback: js.Function1[FileIOError, Any]): Future[Unit] = { - promiseWithError0[FileIOError](fs.chmod(path, mode, _)) - } - - @inline - def closeFuture(fd: FileDescriptor): Future[Unit] = promiseWithError0[FileIOError](fs.close(fd, _)) - - @inline - def existsFuture(path: String): Future[Boolean] = promiseWithErrorAsBoolean[FileIOError](fs.access(path, _)) - - @inline - def fdatasyncFuture(fd: FileDescriptor): Future[Unit] = promiseWithError0[FileIOError](fs.fdatasync(fd, _)) - - @inline - def futimesFuture(fd: FileDescriptor, atime: Integer, mtime: Integer): Future[Unit] = { - promiseWithError0[FileIOError](fs.futimes(fd, atime, mtime, _)) - } - - @inline - def lchmodFuture(path: Buffer | String, mode: FileMode): Future[Unit] = { - promiseWithError0[FileIOError](fs.lchmod(path, mode, _)) - } - - @inline - def lchownFuture(path: Buffer | String, uid: UID, gid: GID): Future[Unit] = { - promiseWithError0[FileIOError](fs.lchown(path, uid, gid, _)) - } - - @inline - def linkFuture(srcpath: Buffer | String, dstpath: Buffer | String): Future[Unit] = { - promiseWithError0[FileIOError](fs.link(srcpath, dstpath, _)) - } - - @inline - def mkdirFuture(path: Buffer | String, mode: FileMode = null): Future[Unit] = { - promiseWithError0[FileIOError](fs.mkdir(path, mode, _)) - } - - @inline - def openFuture(path: Buffer | String, flags: Flags, mode: FileMode = null): Future[FileDescriptor] = { - promiseWithError1[FileIOError, FileDescriptor](fs.open(path, flags, mode, _)) - } - - @inline - def readFuture(fd: FileDescriptor, - buffer: Buffer, - offset: Int, - length: Int, - position: Int): Future[(Int, Buffer)] = { - promiseWithError2[FileIOError, Int, Buffer](Fs.read(fd, buffer, offset, length, position, _)) - } - - @inline - def readdirFuture(path: Buffer | String, - options: String | FileEncodingOptions | RawOptions = null): Future[js.Array[String]] = { - promiseWithError1[FileIOError, js.Array[String]](fs.readdir(path, options, _)) - } - - @inline - def readFileFuture(file: String, options: FileInputOptions = null): Future[js.Any] = { - promiseWithError1[FileIOError, js.Any](fs.readFile(file, options, _)) - } - - @inline - def renameFuture(oldPath: String, newPath: String): Future[Unit] = { - promiseWithError0[FileIOError](fs.rename(oldPath, newPath, _)) - } - - @inline - def realpathFuture(path: String, options: FileEncodingOptions = null): Future[String] = { - promiseWithError1[FileIOError, String](fs.realpath(path, options, _)) - } - - @inline - def rmdirFuture(path: Buffer | String): Future[Unit] = promiseWithError0[FileIOError](fs.rmdir(path, _)) - - @inline - def statFuture(path: String): Future[Stats] = promiseWithError1[FileIOError, Stats](fs.stat(path, _)) - - @inline - def symlinkFuture(target: Buffer | String, path: Buffer | String, `type`: String = null): Future[Unit] = { - promiseWithError0[FileIOError](fs.symlink(target, path, `type`, _)) - } - - @inline - def unlinkFuture(path: Buffer | String): Future[Unit] = promiseWithError0[FileIOError](fs.unlink(path, _)) - - @inline - def unwatchFileFuture(filename: Buffer | String): Future[Unit] = - promiseWithError0[FileIOError](fs.unwatchFile(filename, _)) - - @inline - def utimesFuture(path: Buffer | String, atime: Int, mtime: Int): Future[Unit] = - promiseWithError0[FileIOError](fs.utimes(path, atime, mtime, _)) - - @inline - def watchFuture(filename: String, options: FSWatcherOptions = null): Future[(String, String)] = { - promiseCallback2[String, String](fs.watch(filename, options, _)) - } - - @inline - def writeFuture(fd: FileDescriptor, - buffer: Buffer | Uint8Array, - offset: Integer = null, - length: Integer = null, - position: Integer = null): Future[(FileType, Buffer)] = { - promiseWithError2[FileIOError, Int, Buffer](fs.write(fd, buffer, offset, length, position, _)) - } - - @inline - def writeFuture(fd: FileDescriptor, string: String, position: Int, encoding: String): Future[(FileType, String)] = { - promiseWithError2[FileIOError, Int, String](fs.write(fd, string, position, encoding, _)) - } - - @inline - def writeFuture(fd: FileDescriptor, string: String, position: Int): Future[(FileType, String)] = { - promiseWithError2[FileIOError, Int, String](fs.write(fd, string, position, null, _)) - } - - @inline - def writeFuture(fd: FileDescriptor, string: String): Future[(FileType, String)] = { - promiseWithError2[FileIOError, Int, String](fs.write(fd, string, _)) - } - - @inline - def writeFileFuture(file: String, data: Buffer | String, options: FileOutputOptions = null): Future[Unit] = { - promiseWithError0[FileIOError](fs.writeFile(file, data, options, _)) - } - - } - -} diff --git a/app/lts/src/main/scala/io/scalajs/nodejs/url/URL.scala b/app/lts/src/main/scala/io/scalajs/nodejs/url/URL.scala deleted file mode 100644 index 341a028cf..000000000 --- a/app/lts/src/main/scala/io/scalajs/nodejs/url/URL.scala +++ /dev/null @@ -1,95 +0,0 @@ -package io.scalajs.nodejs.url - -import io.scalajs.nodejs.events.IEventEmitter - -import scala.scalajs.js -import scala.scalajs.js.annotation.JSImport - -/** - * This module has utilities for URL resolution and parsing. Call require('url') to use it. - * @see https://nodejs.org/api/url.html - * @author lawrence.daniels@gmail.com - */ -@js.native -trait URL extends IEventEmitter { - - /** - * Take a parsed URL object, and return a formatted URL string. - * @example url.format(urlObj) - * @since v0.1.25 - */ - def format(urlObj: URLObject): String = js.native - - /** - * Take a URL string, and return an object. - * - * Pass true as the second argument to also parse the query string using the querystring module. If true then the - * query property will always be assigned an object, and the search property will always be a (possibly empty) - * string. If false then the query property will not be parsed or decoded. Defaults to false. - * - * Pass true as the third argument to treat //foo/bar as { host: 'foo', pathname: '/bar' } rather - * than { pathname: '//foo/bar' }. Defaults to false. - * @example url.parse(urlStr[, parseQueryString][, slashesDenoteHost]) - * @since v0.1.25 - */ - def parse(urlStr: String, parseQueryString: String, slashesDenoteHost: Boolean): URLObject = js.native - - /** - * Take a URL string, and return an object. - * - * Pass true as the second argument to also parse the query string using the querystring module. If true then the - * query property will always be assigned an object, and the search property will always be a (possibly empty) - * string. If false then the query property will not be parsed or decoded. Defaults to false. - * - * Pass true as the third argument to treat //foo/bar as { host: 'foo', pathname: '/bar' } rather - * than { pathname: '//foo/bar' }. Defaults to false. - * @example url.parse(urlStr[, parseQueryString][, slashesDenoteHost]) - * @since v0.1.25 - */ - def parse(urlStr: String, parseQueryString: String): URLObject = js.native - - /** - * Take a URL string, and return an object. - * - * Pass true as the second argument to also parse the query string using the querystring module. If true then the - * query property will always be assigned an object, and the search property will always be a (possibly empty) - * string. If false then the query property will not be parsed or decoded. Defaults to false. - * - * Pass true as the third argument to treat //foo/bar as { host: 'foo', pathname: '/bar' } rather - * than { pathname: '//foo/bar' }. Defaults to false. - * @example url.parse(urlStr[, parseQueryString][, slashesDenoteHost]) - */ - def parse(urlStr: String, slashesDenoteHost: Boolean): URLObject = js.native - - /** - * Take a URL string, and return an object. - * - * Pass true as the second argument to also parse the query string using the querystring module. If true then the - * query property will always be assigned an object, and the search property will always be a (possibly empty) - * string. If false then the query property will not be parsed or decoded. Defaults to false. - * - * Pass true as the third argument to treat //foo/bar as { host: 'foo', pathname: '/bar' } rather - * than { pathname: '//foo/bar' }. Defaults to false. - * @example url.parse(urlStr[, parseQueryString][, slashesDenoteHost]) - */ - def parse(urlStr: String): URLObject = js.native - - /** - * Take a base URL, and a href URL, and resolve them as a browser would for an anchor tag. - * Examples: - * url.resolve('/one/two/three', 'four') // '/one/two/four' - * url.resolve('http://example.com/', '/one') // 'http://example.com/one' - * url.resolve('http://example.com/one', '/two') // 'http://example.com/two' - * @example url.resolve(from, to) - */ - def resolve(from: String, to: String): String = js.native - -} - -/** - * URL Singleton - * @author lawrence.daniels@gmail.com - */ -@js.native -@JSImport("url", JSImport.Namespace) -object URL extends URL diff --git a/app/lts/src/main/scala/io/scalajs/nodejs/url/URLObject.scala b/app/lts/src/main/scala/io/scalajs/nodejs/url/URLObject.scala deleted file mode 100644 index 20a454e63..000000000 --- a/app/lts/src/main/scala/io/scalajs/nodejs/url/URLObject.scala +++ /dev/null @@ -1,96 +0,0 @@ -package io.scalajs.nodejs.url - -import scala.scalajs.js - -/** - * Parsed URL Object - * @author lawrence.daniels@gmail.com - */ -@js.native -trait URLObject extends js.Object { - - /** - * The auth property is the username and password portion of the URL, also referred to as "userinfo". - * This string subset follows the protocol and double slashes (if present) and precedes the host component, - * delimited by an ASCII "at sign" (@). The format of the string is {username}[:{password}], with - * the [:{password}] portion being optional. - * @example 'user:pass' - */ - var auth: js.UndefOr[String] = js.native - - /** - * The hash property consists of the "fragment" portion of the URL including the leading ASCII hash (#) character. - * @example '#hash' - */ - var hash: js.UndefOr[String] = js.native - - /** - * The host property is the full lower-cased host portion of the URL, including the port if specified. - * @example 'host.com:8080' - */ - var host: js.UndefOr[String] = js.native - - /** - * The hostname property is the lower-cased host name portion of the host component without the port included. - * @example 'host.com' - */ - var hostname: js.UndefOr[String] = js.native - - /** - * The href property is the full URL string that was parsed with both the protocol and host components - * converted to lower-case. - * @example {{{ http://user:pass@host.com:8080/p/a/t/h?query=string#hash }}} - */ - var href: js.UndefOr[String] = js.native - - /** - * The path property is a concatenation of the pathname and search components. - * @example '/p/a/t/h?query=string' - */ - var path: js.UndefOr[String] = js.native - - /** - * The pathname property consists of the entire path section of the URL. This is everything following the host - * (including the port) and before the start of the query or hash components, delimited by either the ASCII - * question mark (?) or hash (#) characters. - * @example '/p/a/t/h' - */ - var pathname: js.UndefOr[String] = js.native - - /** - * The port property is the numeric port portion of the host component. - * @example '8080' - */ - var port: js.UndefOr[String] = js.native - - /** - * The protocol property identifies the URL's lower-cased protocol scheme. - * @example 'http:' - */ - var protocol: js.UndefOr[String] = js.native - - /** - * The query property is either the query string without the leading ASCII question mark (?), or an object returned - * by the querystring module's parse() method. Whether the query property is a string or object is determined by the - * parseQueryString argument passed to url.parse(). - * - * If returned as a string, no decoding of the query string is performed. If returned as an object, both keys and - * values are decoded. - * @example 'query=string' or {'query': 'string'} - */ - var query: js.UndefOr[String] = js.native - - /** - * The search property consists of the entire "query string" portion of the URL, including the leading ASCII - * question mark (?) character. - * @example '?query=string' - */ - var search: js.UndefOr[String] = js.native - - /** - * The slashes property is a boolean with a value of true if two ASCII forward-slash characters (/) are required - * following the colon in the protocol. - */ - var slashes: js.UndefOr[Boolean] = js.native - -} diff --git a/app/lts/src/test/resources/1.txt b/app/lts/src/test/resources/1.txt deleted file mode 100644 index 5ab2f8a43..000000000 --- a/app/lts/src/test/resources/1.txt +++ /dev/null @@ -1 +0,0 @@ -Hello \ No newline at end of file diff --git a/app/lts/src/test/resources/fileA1.txt b/app/lts/src/test/resources/fileA1.txt deleted file mode 100644 index 5e1c309da..000000000 --- a/app/lts/src/test/resources/fileA1.txt +++ /dev/null @@ -1 +0,0 @@ -Hello World \ No newline at end of file diff --git a/app/lts/src/test/resources/fileA2.txt b/app/lts/src/test/resources/fileA2.txt deleted file mode 100644 index 5e1c309da..000000000 --- a/app/lts/src/test/resources/fileA2.txt +++ /dev/null @@ -1 +0,0 @@ -Hello World \ No newline at end of file diff --git a/app/lts/src/test/resources/fileB1.txt b/app/lts/src/test/resources/fileB1.txt deleted file mode 100644 index 972263ed9..000000000 --- a/app/lts/src/test/resources/fileB1.txt +++ /dev/null @@ -1 +0,0 @@ -Goodbye Cruel World \ No newline at end of file diff --git a/app/lts/src/test/resources/fileB2.txt b/app/lts/src/test/resources/fileB2.txt deleted file mode 100644 index 972263ed9..000000000 --- a/app/lts/src/test/resources/fileB2.txt +++ /dev/null @@ -1 +0,0 @@ -Goodbye Cruel World \ No newline at end of file diff --git a/app/lts/src/test/resources/watchfile.json b/app/lts/src/test/resources/watchfile.json deleted file mode 100644 index 62b27ec83..000000000 --- a/app/lts/src/test/resources/watchfile.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "scalajs-io", - "version": "0.4.2", - "private": true, - "dependencies": { - "async": "^2.0.1", - "bcrypt": "^1.0.2", - "bignum": "^0.12.5", - "body-parser": "^1.15.0", - "buffermaker": "^1.2.0", - "cassandra-driver": "^3.0.2", - "cheerio": "^0.22.0", - "colors": "^1.1.2", - "cookie": "^0.3.1", - "cookie-parser": "^1.4.3", - "csv-parse": "^1.1.3", - "drama": "^0.1.3", - "express": "^4.13.4", - "express-csv": "^0.6.0", - "express-ws": "^2.0.0-beta", - "feedparser-promised": "^1.1.1", - "gridfs-stream": "^1.1.1", - "html": "^0.0.10", - "html-to-json": "^0.6.0", - "htmlparser2": "^3.9.2", - "jquery": "^3.1.1", - "jsdom": "^9.9.1", - "jwt-simple": "^0.5.0", - "kafka-node": "^1.3.0", - "kafka-rest": "0.0.4", - "md5": "^2.2.1", - "memory-fs": "^0.3.0", - "moment": "^2.17.1", - "moment-timezone": "^0.5.11", - "mongodb": "^2.1.18", - "mysql": "^2.10.2", - "node-embedded-mongodb": "^0.0.3", - "node-zookeeper-client": "^0.2.2", - "numeral": "^2.0.4", - "oppressor": "0.0.1", - "readline": "^1.3.0", - "rx": "^4.1.0", - "should": "^11.1.2", - "socket.io": "^1.7.2", - "source-map-support": "^0.4.14", - "splitargs": "0.0.7", - "tingodb": "^0.5.1", - "transducers-js": "^0.4.174", - "watch": "^0.18.0", - "xml2js": "^0.4.17" - } -} diff --git a/app/lts/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala b/app/lts/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala deleted file mode 100644 index 4ef9a6522..000000000 --- a/app/lts/src/test/scala/io/scalajs/nodejs/fs/FsAsyncTest.scala +++ /dev/null @@ -1,44 +0,0 @@ -package io.scalajs.nodejs.fs - -import io.scalajs.nodejs.buffer.Buffer -import org.scalatest.{AsyncFunSpec, BeforeAndAfterEach} - -import scala.concurrent.{ExecutionContext, Future} - -class FsAsyncTest extends AsyncFunSpec with BeforeAndAfterEach { - - private val file = "x.File.txt" - - override def afterEach(): Unit = { - if (Fs.existsSync(file)) Fs.unlinkSync(file) - } - - override implicit val executionContext = ExecutionContext.Implicits.global - - describe("Fs") { - it("support basic operations") { - for { - _ <- Future.successful("") - _ <- Fs.writeFileFuture(file, "content") - exists <- Fs.existsFuture(file) - readBuffer <- Fs.readFileFuture(file) - _ <- Fs.unlinkFuture(file) - existsAfterUnlink <- Fs.existsFuture(file) - } yield { - assert(exists) - assert(readBuffer.asInstanceOf[Buffer].toString() == "content") - assert(!existsAfterUnlink) - } - } - - describe("existsFuture") { - it("should return false if not exist") { - for { - exists <- Fs.existsFuture(file) - } yield { - assert(!exists) - } - } - } - } -} diff --git a/app/lts/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala b/app/lts/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala deleted file mode 100644 index e839d079c..000000000 --- a/app/lts/src/test/scala/io/scalajs/nodejs/fs/FsTest.scala +++ /dev/null @@ -1,77 +0,0 @@ -package io.scalajs.nodejs.fs - -import io.scalajs.JSON -import io.scalajs.nodejs.setImmediate -import io.scalajs.nodejs.util.Util -import io.scalajs.util.ScalaJsHelper._ -import org.scalatest.FunSpec - -/** - * File System (Fs) Tests - * @author lawrence.daniels@gmail.com - */ -class FsTest extends FunSpec { - - describe("Fs") { - - it("supports watching files") { - val watcher = Fs.watch("./app/lts/src/test/resources/", (eventType, file) => { - info(s"watcher: eventType = '$eventType' file = '$file'") - }) - info(s"watcher: ${Util.inspect(watcher)}") - - setImmediate( - () => - Fs.writeFile("./app/lts/src/test/resources/1.txt", "Hello", error => { - if (isDefined(error)) { - alert(s"error: ${JSON.stringify(error)}") - } - }) - ) - } - - it("should stream data") { - val file1 = "./app/lts/src/test/resources/fileA1.txt" - val file2 = "./app/lts/src/test/resources/fileA2.txt" - val file3 = "./app/lts/src/test/resources/fileC2.txt" - - val readable = Fs.createReadStream(file1) - val writable = Fs.createWriteStream(file2) - readable.setEncoding("utf8") - readable.onData[String](chunk => writable.write(chunk)) - writable.onFinish { () => - info("Comparing file sizes:") - info(s"$file1 is ${Fs.statSync(file1).size} bytes") - info(s"$file2 is ${Fs.statSync(file2).size} bytes") - assert(Fs.statSync(file1).size == Fs.statSync(file2).size) - - info("should rename the file") - Fs.renameSync(file2, file3) - assert(Fs.statSync(file2).isFile()) - - info("should delete the file") - Fs.unlinkSync(file3) - val deleted = !Fs.existsSync(file3) - info(s"deleted? $deleted") - assert(deleted) - } - } - - it("should pipe data from a Readable to a Writable") { - val file1 = "./app/lts/src/test/resources/fileB1.txt" - val file2 = "./app/lts/src/test/resources/fileB2.txt" - - val readable = Fs.createReadStream(file1) - val writable = Fs.createWriteStream(file2) - readable.pipe(writable) - writable.onFinish { () => - info("Comparing file sizes:") - info(s"$file1 is ${Fs.statSync(file1).size} bytes") - info(s"$file2 is ${Fs.statSync(file2).size} bytes") - assert(Fs.statSync(file1).size == Fs.statSync(file2).size) - } - } - - } - -} diff --git a/app/lts/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala b/app/lts/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala deleted file mode 100644 index a50d4ec74..000000000 --- a/app/lts/src/test/scala/io/scalajs/nodejs/url/URLObjectTest.scala +++ /dev/null @@ -1,38 +0,0 @@ -package io.scalajs.nodejs.url - -import io.scalajs.util.JSONHelper._ -import io.scalajs.util.JsUnderOrHelper._ -import org.scalatest.FunSpec - -/** - * URLObject Tests - * @author lawrence.daniels@gmail.com - */ -class URLObjectTest extends FunSpec { - - describe("URLObject") { - - val originalUrl = "https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=node" - val urlObject = URL.parse(originalUrl) - - it("should break down URLs into components") { - assert( - urlObject.toJson == """{"protocol":"https:","slashes":true,"auth":null,"host":"www.google.com","port":null,"hostname":"www.google.com","hash":"#q=node","search":"?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","query":"sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","pathname":"/webhp","path":"/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","href":"https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=node"}""" - ) - } - - it("should be properly extracted") { - assert(urlObject.query ?== "sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8") - } - - it("should properly extract the search query") { - assert(urlObject.search ?== "?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8") - } - - it("should reconstituted the URL to match the original") { - assert(URL.format(urlObject) == originalUrl) - } - - } - -} diff --git a/app/lts/src/test/scala/io/scalajs/nodejs/url/URLTest.scala b/app/lts/src/test/scala/io/scalajs/nodejs/url/URLTest.scala deleted file mode 100644 index e0706883d..000000000 --- a/app/lts/src/test/scala/io/scalajs/nodejs/url/URLTest.scala +++ /dev/null @@ -1,39 +0,0 @@ -package io.scalajs.nodejs -package url - -import io.scalajs.util.JSONHelper._ -import io.scalajs.util.JsUnderOrHelper._ -import org.scalatest._ - -/** - * URL Tests - * @author lawrence.daniels@gmail.com - */ -class URLTest extends FunSpec { - - describe("URL") { - - val originalUrl = "https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=node" - val parsedUrl = URL.parse(originalUrl) - - it("should break down URLs into components") { - assert( - parsedUrl.toJson == """{"protocol":"https:","slashes":true,"auth":null,"host":"www.google.com","port":null,"hostname":"www.google.com","hash":"#q=node","search":"?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","query":"sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","pathname":"/webhp","path":"/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8","href":"https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=node"}""" - ) - } - - it("should be properly extracted") { - assert(parsedUrl.query ?== "sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8") - } - - it("should properly extract the search query") { - assert(parsedUrl.search ?== "?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8") - } - - it("should reconstituted the URL to match the original") { - assert(URL.format(parsedUrl) == originalUrl) - } - - } - -} diff --git a/build.sbt b/build.sbt index 54c4a4c8c..e4a5c12e2 100644 --- a/build.sbt +++ b/build.sbt @@ -56,8 +56,8 @@ lazy val core = (project in file("./core")) ) lazy val root = (project in file(".")) - .aggregate(core, common, current, lts) - .dependsOn(core, common, current, lts) + .aggregate(core, common, current) + .dependsOn(core, common, current) .enablePlugins(ScalaJSPlugin) .settings(commonSettings) .settings(commonScalaJsSettings) @@ -117,26 +117,6 @@ lazy val current = (project in file("./app/current")) .settings(commonMacroParadiseSetting) .dependsOn(core) -lazy val lts = (project in file("./app/lts")) - .dependsOn(common) - .enablePlugins(ScalaJSPlugin) - .settings(commonSettings) - .settings(commonScalaJsSettings) - .settings( - name := "nodejs-lts", - version := apiVersion, - organization := "io.scalajs", - description := "NodeJS LTS v6.11.4 API for Scala.js", - homepage := Some(url("https://github.com/scalajs-io/nodejs")), - libraryDependencies ++= Seq( - "org.scala-lang" % "scala-reflect" % scalaVersion.value, - "org.scalactic" %% "scalactic" % scalacticVersion, - "org.scalatest" %%% "scalatest" % scalatestVersion % "test" - ) - ) - .settings(commonMacroParadiseSetting) - .dependsOn(core) - lazy val publishingSettings = Seq( sonatypeProfileName := "org.xerial", publishMavenStyle := true,