installed pty
[VSoRC/.git] / node_modules / node-pty / scripts / post-install.js
1 var fs = require('fs');
2 var path = require('path');
3
4 var RELEASE_DIR = path.join(__dirname, '..', 'build', 'Release');
5 var BUILD_FILES = [
6   path.join(RELEASE_DIR, 'conpty.node'),
7   path.join(RELEASE_DIR, 'conpty.pdb'),
8   path.join(RELEASE_DIR, 'conpty_console_list.node'),
9   path.join(RELEASE_DIR, 'conpty_console_list.pdb'),
10   path.join(RELEASE_DIR, 'pty.node'),
11   path.join(RELEASE_DIR, 'pty.pdb'),
12   path.join(RELEASE_DIR, 'winpty-agent.exe'),
13   path.join(RELEASE_DIR, 'winpty-agent.pdb'),
14   path.join(RELEASE_DIR, 'winpty.dll'),
15   path.join(RELEASE_DIR, 'winpty.pdb')
16 ];
17
18 cleanFolderRecursive = function(folder) {
19   var files = [];
20   if( fs.existsSync(folder) ) {
21     files = fs.readdirSync(folder);
22     files.forEach(function(file,index) {
23       var curPath = path.join(folder, file);
24       if(fs.lstatSync(curPath).isDirectory()) { // recurse
25         cleanFolderRecursive(curPath);
26         fs.rmdirSync(curPath);
27       } else if (BUILD_FILES.indexOf(curPath) < 0){ // delete file
28         fs.unlinkSync(curPath);
29       }
30     });
31   }
32 };
33
34 try {
35   cleanFolderRecursive(RELEASE_DIR);
36 } catch(e) {
37   console.log(e);
38   //process.exit(1);
39 } finally {
40   process.exit(0);
41 }