~ubuntu-branches/ubuntu/wily/node-tmp/wily

« back to all changes in this revision

Viewing changes to test/unsafe-sync.js

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-03-10 19:47:11 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20150310194711-497k54p1pge5csb7
Tags: 0.0.25-1
* New upstream release.
* Update copyright years in copyright file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
var
 
2
  fs    = require('fs'),
 
3
  join  = require('path').join,
 
4
  spawn = require('./spawn-sync');
 
5
 
 
6
var unsafe = spawn.arg;
 
7
 
 
8
try {
 
9
  var result = spawn.tmpFunction({ unsafeCleanup: unsafe });
 
10
  try {
 
11
    // file that should be removed
 
12
    var fd = fs.openSync(join(result.name, 'should-be-removed.file'), 'w');
 
13
    fs.closeSync(fd);
 
14
 
 
15
    // in tree source
 
16
    var symlinkSource = join(__dirname, 'symlinkme');
 
17
    // testing target
 
18
    var symlinkTarget = join(result.name, 'symlinkme-target');
 
19
 
 
20
    // symlink that should be removed but the contents should be preserved.
 
21
    fs.symlinkSync(symlinkSource, symlinkTarget, 'dir');
 
22
 
 
23
    spawn.out(result.name, spawn.exit);
 
24
  } catch (e) {
 
25
    spawn.err(e.toString(), spawn.exit);
 
26
  }
 
27
}
 
28
catch (e) {
 
29
  spawn.err(err, spawn.exit);
 
30
}
 
31