├── README.md ├── index.js ├── package-lock.json ├── package.json └── screenshot.png /README.md: -------------------------------------------------------------------------------- 1 | # Dat Party 🎉 2 | A command for running `dat share` in all folders in the directory that you run the `dat-party` command in. Auto detection of new folders is supported. 3 | 4 | ``` 5 | npm install -g dat-party 6 | cd folder-of-folders-i-want-to-share 7 | dat-party 8 | ``` 9 | 10 | ![Screenshot](screenshot.png) 11 | 12 | **Warning** I coded this up in an hour. Mileage may vary ;). 13 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const { exec } = require('child_process'); 4 | const fs = require('fs'); 5 | var datArchives = [] 6 | 7 | function datShare(dir) { 8 | exec(`cd ${dir} && dat share`, (error, stdout, stderr) => { 9 | if (error) { 10 | console.error(`exec error: ${error}`); 11 | return; 12 | } 13 | console.log(`${stdout}`); 14 | console.log(`${stderr}`); 15 | }); 16 | setTimeout(() => { 17 | exec(`cd ${dir} && dat status`, (error, stdout, stderr) => { 18 | if (error) { 19 | console.error(`exec error: ${error}`); 20 | return; 21 | } 22 | console.log(`Sharing ${dir} 🎉 `) 23 | console.log(`${stdout}`); 24 | console.log(`${stderr}`); 25 | }) 26 | }, 2000) 27 | } 28 | 29 | setInterval(() => { 30 | fs.readdir(process.cwd(), (err, files) => { 31 | files.forEach(file => { 32 | if (fs.statSync(file).isDirectory() && !datArchives.includes(file)) { 33 | datArchives.push(file) 34 | datShare(file) 35 | } 36 | }) 37 | }) 38 | }, 2000) 39 | 40 | console.log(``) 41 | console.log(` 🎉 Starting the party 🎉 `) 42 | console.log(``) 43 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dat-party", 3 | "version": "0.0.0", 4 | "lockfileVersion": 1 5 | } 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dat-party", 3 | "version": "0.0.2", 4 | "description": "A command that will dat share all folders in the folder you run dat-party command in.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "bin": { 10 | "dat-party": "./index.js" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/rjsteinert/dat-party.git" 15 | }, 16 | "bugs": { 17 | "url": "https://github.com/rjsteinert/dat-party/issues" 18 | }, 19 | "homepage": "https://github.com/rjsteinert/dat-party#readme", 20 | "author": "R.J. Steinert", 21 | "license": "ISC", 22 | "dependencies": {} 23 | } 24 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rjcorwin/dat-party/a6200da9ab8cc53ca2962e8ca2afd32f2c3d05e0/screenshot.png --------------------------------------------------------------------------------