symlink-write.js 745 B

123456789101112131415161718192021222324252627
  1. var fstream = require('../fstream.js')
  2. var notOpen = false
  3. process.chdir(__dirname)
  4. fstream
  5. .Writer({
  6. path: 'path/to/symlink',
  7. linkpath: './file',
  8. isSymbolicLink: true,
  9. mode: '0755' // octal strings supported
  10. })
  11. .on('close', function () {
  12. notOpen = true
  13. var fs = require('fs')
  14. var s = fs.lstatSync('path/to/symlink')
  15. var isSym = s.isSymbolicLink()
  16. console.log((isSym ? '' : 'not ') + 'ok 1 should be symlink')
  17. var t = fs.readlinkSync('path/to/symlink')
  18. var isTarget = t === './file'
  19. console.log((isTarget ? '' : 'not ') + 'ok 2 should link to ./file')
  20. })
  21. .end()
  22. process.on('exit', function () {
  23. console.log((notOpen ? '' : 'not ') + 'ok 3 should be closed')
  24. console.log('1..3')
  25. })