10 examples of 'node js fs promise' in JavaScript

Every line of 'node js fs promise' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
53function ensureFs() {
54 return fsInited ? Promise.resolve() : fs.initAsync(0).then(() => fsInited = true);
55}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

110function fs() {
111 return require("fs");
112}
29function deleteFileAsPromise(entry, path) {
30 return new Promise((resolve, reject) => {
31 entry.getFile(path, {}, (entry) => {
32 entry.remove(resolve);
33 }, reject);
34 });
35}
49function unlinkPromise(file) {
50 return new Promise((resolve, reject) => {
51 fs.unlink(file, (err) => {
52 if (err) {
53 reject(err);
54 }
55 else {
56 resolve();
57 }
58 });
59 });
60}
129readFile(filePath: string, format = 'utf8') {
130 return new Promise<string>((resolve, reject) => {
131 fs.readFile(filePath, format, (err: any, content: any) => {
132 if (err) {
133 reject(err);
134 } else {
135 resolve(content);
136 }
137 });
138 });
139}
312.otherwise(function localfilesystemFn(e) {
313 throw err;
314});
264export function fileSystem(path: string|string[]): NodeFileSystem {
265 return new NodeFileSystem(path);
266}
53function getDirectoryAsPromise(entry, path) {
54 return new Promise((resolve, reject) => {
55 entry.getDirectory(path, { create: true }, resolve, reject);
56 });
57}
101async lstatPromise(p: PortablePath): Promise<never> {
102 throw makeError();
103}
69private getNpmPath() {
70 return new Promise((resolve, reject) => {
71 which('npm', (err, npmPath) => {
72 if (err && ! npmPath) {
73 if (this.app) {
74 this.app.logger.error(`npm -> path error: ${err}`);
75 }
76 reject(err);
77 } else {
78 if (this.app) {
79 this.app.logger.log(`npm -> path: ${npmPath}`);
80 }
81 resolve(npmPath);
82 }
83 });
84 });
85}

Related snippets