Code files

This commit is contained in:
Akhil
2017-07-31 11:33:31 +05:30
parent 073a63ebdd
commit b9ae409ec0
801 changed files with 17535 additions and 0 deletions
@@ -0,0 +1,26 @@
'use strict'
const fs = require('fs')
const {execSync} = require('child_process')
const file = process.argv[2]
if (!file) {
console.error('specify a file')
process.exit(1)
}
try {
fs.accessSync(file)
console.error('file already exists')
process.exit(1)
} catch (e) {
makeIt()
}
function makeIt() {
const nobody = Number(execSync('id -u nobody').toString().trim())
const fd = fs.openSync(file, 'w')
fs.fchmodSync(fd, 0)
fs.fchownSync(fd, nobody, nobody)
console.log(file + ' created')
}
@@ -0,0 +1,25 @@
'use strict'
const fs = require('fs')
const {execSync} = require('child_process')
const file = process.argv[2]
if (!file) {
console.error('specify a file')
process.exit(1)
}
try {
fs.accessSync(file)
console.error('file already exists')
process.exit(1)
} catch (e) {
makeIt()
}
function makeIt() {
const nobody = Number(execSync('id -u nobody').toString().trim())
fs.writeFileSync(file, '')
fs.chownSync(file, nobody, nobody)
fs.chmodSync(file, 0)
console.log(file + ' created')
}