Files: 67c0e15a98a66eb99db2251478505d6f3d37535c / test / test-50-promisify / test-x-index.js
649 bytesRaw
1 | ; |
2 | |
3 | var promisify = require('util').promisify; |
4 | if (!promisify) return console.log('ok'); |
5 | |
6 | var fs = require('fs'); |
7 | var execAsync = promisify(require('child_process').exec); |
8 | var existsAsync = promisify(fs.exists); |
9 | var readAsync = promisify(fs.read); |
10 | |
11 | execAsync('whoami').then(function (output) { |
12 | console.log(JSON.stringify(output)); |
13 | existsAsync('./main.js').then(function (existence) { |
14 | console.log(existence); |
15 | fs.open('./main.js', 'r', function (error, fd) { |
16 | if (error) return; |
17 | readAsync(fd, Buffer.alloc(10), 0, 10, 0).then(function (tuple) { |
18 | console.log(JSON.stringify(tuple)); |
19 | }); |
20 | }); |
21 | }); |
22 | }); |
23 |
Built with git-ssb-web