-
Notifications
You must be signed in to change notification settings - Fork 0
/
node_play.js
153 lines (107 loc) · 5.15 KB
/
node_play.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
const file_util = require(`./util/file_util.js`)
// NODE MODULES:
const path = require(`path`)
const fs = require(`fs`)
// const os = require(`os`)
const cp = require(`child_process`)
// const buff = require(`buffer`)
console.log(`\x1b[35m%s\x1b[0m`, `//==================================//`);
console.log(`\x1b[35m%s\x1b[0m`, `Hello! Node Play process initiated! ^_^`);
// GLOBAL VARS:
// console.log(__dirname);
// console.log(__filename);
// let test = path.join(__dirname, process.argv[2] || 'target_dirs/testing_grounds');
// console.log(test);
// console.log, console.info, console.warn, console.error, console.dir, console.time, console.timeEnd, console.trace, console.assert
// process
// // PATH MODULE
// //--------------------------------------------------------------------------//
// path.basename('./target_dirs/testing_grounds/first.json'); // returns first.json
// path.dirname('./target_dirs/testing_grounds/first.json'); // returns ./target_dirs/testing_grounds
// path.extname('./target_dirs/testing_grounds/first.json'); // returns .json
// path.format({ root: '/ignored', dir: '/home/user/dir', base: 'file.txt' }); // returns '/home/user/dir/file.txt'
// path.isAbsolute('/'); // returns true
// path.join('target_dirs', 'testing_grounds');
// path.normalize('../archiver/target_dirs/sub_folder/..'); // returns ../archiver/target_dirs
// path.parse('../archiver/target_dirs/sub_folder/second.json') // returns a path obj
// path.relative('../archiver/target_dirs/sub_folder', './mapper.js')// returns relative path
// path.resolve('../archiver/target_dirs/sub_folder/second.json') // returns an absolute path
// path.sep // returns platform-specific path segment separator
// // FS MODULE
// //--------------------------------------------------------------------------//
// fs.mkdirSync()
// fs.rmdirSync()
// fs.existsSync()
// fs.statSync()
// fs.readdirSync()
// fs.readFileSync()
// fs.writeFile()
// fs.open(path.join(__dirname, 'map.json'));
// // OS MODULE
// //--------------------------------------------------------------------------//
// console.log(os.platform())
// let cache = require.cache;
// console.log(cache);
// for (key in cache) {
// console.log(cache[key].Module);
// }
// console.log(global.process.title);
// console.log(global.process.stdout);
// console.log(process);
// // CHILD_PROCESS MODULE
// //--------------------------------------------------------------------------//
// let basename = `Split.2016.1080p.BRRip.x264.AAC-ETRG.mp4`
let basename = `Superstar\\ The\\ Karen\\ Carpenter\\ \\"Story\\".avi`
// cp.exec('open ./map.json');
// cp.exec('open -a "Google Chrome" https://nodejs.org/en/');
// cp.exec(`open /Users/jamesrutledge/Movies/${basename}`);
cp.exec(`open -a "VLC" /Users/jamesrutledge/Movies/${basename}`);
// cp.execSync()
// cp.execFile('node', ['--version'], (err, stdout, stderr) => {
// if (err) {
// throw err;
// }
// console.log(stdout);
// });
// cp.execFileSync()
// cp.fork('./mapper.js'); // <-- spawns a new node instance with 'process.execPath'
// // SPAWNS LS & OBTAINS DIR DATA
// //--------------------------------------------------------------------------//
// let ls = cp.spawn('ls', ['-lh', './target_dirs']);
// ls.stdout.on('data', (data) => console.log(`stdout: ${data}`));
// ls.stderr.on('data', (data) => console.log(`stderr: ${data}`));
// ls.on('close', (code) => console.log(`child process exited with code ${code}`));
// cp.spawnSync()
// // SPAWNS MDLS & OBTAINS META DATA
// //--------------------------------------------------------------------------//
// // great resource: https://www.macissues.com/2014/05/12/how-to-look-up-file-metadata-in-os-x/
// let mdls = cp.spawn('mdls', ['/Users/jamesrutledge/Movies/GO.m4v']);
// mdls.stdout.on('data', (data) => {
// console.log(`stdout: ${data}`);
// })
// SPAWNS MDLS & OBTAINS META DATA ATTRIBUTE
// --------------------------------------------------------------------------//
// let mdls = cp.spawn('mdls', ['-name', 'kMDItemDurationSeconds', '/Users/jamesrutledge/Movies/GO.m4v']);
// mdls.stdout.on('data', (data) => {
// let dataStr = data.toString("utf-8");
// let dur = parseFloat(dataStr.split('=')[1]);
// // console.log(`stdout: ${data}`)
// console.log(`stdout: `)
// console.log(dataStr);
// console.log(dataStr.length);
// console.log(typeof dataStr);
// console.log(dur);
// });
// mdls.stderr.on('data', (data) => console.log(`stderr: ${data}`));
// mdls.on('close', (code) => console.log(`child process exited with code ${code}`));
// // SPAWNS MDLS - OBTAINS META DATA - GENERATES JSON FILE
// //--------------------------------------------------------------------------//
// let mdls = cp.spawn('mdls', ['/Users/jamesrutledge/Movies/GO.m4v']);
// mdls.stdout.on('data', (data) => {
// let dataStr = data.toString("utf-8");
// console.log(`stdout: ${dataStr}`);
// file_util.methods.saveJSON(file_util.methods.pather([__dirname, '..', 'data'], 'metadata', 'json'), { dataStr });
// })
// mdls.stderr.on('data', (data) => console.log(`stderr: ${data}`));
// mdls.on('close', (code) => console.log(`child process exited with code ${code}`));
console.log(`\x1b[35m%s\x1b[0m`, `//==================================//`);