source: frontend/node_modules/mz/fs.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.0 KB
Line 
1
2var Promise = require('any-promise')
3var fs
4try {
5 fs = require('graceful-fs')
6} catch(err) {
7 fs = require('fs')
8}
9
10var api = [
11 'appendFile',
12 'chmod',
13 'chown',
14 'close',
15 'fchmod',
16 'fchown',
17 'fdatasync',
18 'fstat',
19 'fsync',
20 'ftruncate',
21 'futimes',
22 'lchown',
23 'link',
24 'lstat',
25 'mkdir',
26 'open',
27 'read',
28 'readFile',
29 'readdir',
30 'readlink',
31 'realpath',
32 'rename',
33 'rmdir',
34 'stat',
35 'symlink',
36 'truncate',
37 'unlink',
38 'utimes',
39 'write',
40 'writeFile'
41]
42
43typeof fs.access === 'function' && api.push('access')
44typeof fs.copyFile === 'function' && api.push('copyFile')
45typeof fs.mkdtemp === 'function' && api.push('mkdtemp')
46
47require('thenify-all').withCallback(fs, exports, api)
48
49exports.exists = function (filename, callback) {
50 // callback
51 if (typeof callback === 'function') {
52 return fs.stat(filename, function (err) {
53 callback(null, !err);
54 })
55 }
56 // or promise
57 return new Promise(function (resolve) {
58 fs.stat(filename, function (err) {
59 resolve(!err)
60 })
61 })
62}
Note: See TracBrowser for help on using the repository browser.