mirror of
https://github.com/lennyhans/systemd-to-openrc.git
synced 2026-03-09 20:31:09 +00:00
Add basic cli working with static input
This commit is contained in:
parent
331d7980be
commit
28fa44e17c
2 changed files with 48 additions and 0 deletions
36
cli.js
Executable file
36
cli.js
Executable file
|
|
@ -0,0 +1,36 @@
|
||||||
|
import { readFile, writeFile } from 'node:fs/promises';
|
||||||
|
import { convert } from './magic.js';
|
||||||
|
|
||||||
|
async function reader(path){
|
||||||
|
try {
|
||||||
|
const contents = await readFile(path, { encoding: 'utf8' });
|
||||||
|
// console.log(contents)
|
||||||
|
return contents;
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function writer(path, content){
|
||||||
|
try {
|
||||||
|
await writeFile(path, content, { encoding: 'utf8' });
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function convertForConsole(convertFunction){
|
||||||
|
return async function(filePath){
|
||||||
|
const sourceFile = await reader("./systemd-unit.conf");
|
||||||
|
const converted = convertFunction(sourceFile);
|
||||||
|
await writer("./init.conf", converted.result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setup(){
|
||||||
|
const convertFunction = convertForConsole(convert)
|
||||||
|
convertFunction();
|
||||||
|
}
|
||||||
|
|
||||||
|
setup();
|
||||||
12
package.json
Normal file
12
package.json
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"name": "systemd-to-openrc",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "The #!openrc-run generator",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"type": "module",
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC"
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue