Minor changes
This commit is contained in:
+9
-28
@@ -5,7 +5,8 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "flow-remove-types src/ -d out/",
|
||||
"buildWithMaps": "flow-remove-types src/ -d out/ --pretty --sourcemaps",
|
||||
"buildWithMaps":
|
||||
"flow-remove-types src/ -d out/ --pretty --sourcemaps",
|
||||
"start": "npm run build && node out/doroundmath.js",
|
||||
"start-db": "npm run build && node out/dbaccess.js",
|
||||
"nodemon": "nodemon --watch src --delay 1 --exec npm start",
|
||||
@@ -19,10 +20,7 @@
|
||||
"author": "Federico Kereki",
|
||||
"license": "ISC",
|
||||
"babel": {
|
||||
"presets": [
|
||||
"env",
|
||||
"flow"
|
||||
]
|
||||
"presets": ["env", "flow"]
|
||||
},
|
||||
"eslintConfig": {
|
||||
"parserOptions": {
|
||||
@@ -31,41 +29,24 @@
|
||||
},
|
||||
"parser": "babel-eslint",
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node": true,
|
||||
"es6": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:flowtype/recommended"
|
||||
],
|
||||
"plugins": [
|
||||
"babel",
|
||||
"flowtype"
|
||||
],
|
||||
"extends": ["eslint:recommended", "plugin:flowtype/recommended"],
|
||||
"plugins": ["babel", "flowtype"],
|
||||
"rules": {
|
||||
"no-console": "off",
|
||||
"no-var": "error",
|
||||
"prefer-const": "error"
|
||||
}
|
||||
},
|
||||
"eslintIgnore": [
|
||||
"**/out/*.js"
|
||||
],
|
||||
"eslintIgnore": ["**/out/*.js"],
|
||||
"flow-coverage-report": {
|
||||
"concurrentFiles": 1,
|
||||
"excludeGlob": [
|
||||
"node_modules/**"
|
||||
],
|
||||
"includeGlob": [
|
||||
"src/**/*.js"
|
||||
],
|
||||
"excludeGlob": ["node_modules/**"],
|
||||
"includeGlob": ["src/**/*.js"],
|
||||
"threshold": 90,
|
||||
"type": [
|
||||
"text",
|
||||
"html",
|
||||
"json"
|
||||
]
|
||||
"type": ["text", "html", "json"]
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 4,
|
||||
|
||||
@@ -1,22 +1,15 @@
|
||||
/* @flow */
|
||||
"use strict";
|
||||
|
||||
const child_process = require("child_process");
|
||||
const { promisify } = require("util");
|
||||
|
||||
child_process.exec = promisify(child_process.exec);
|
||||
|
||||
async function getDirectory(path: ?string) {
|
||||
async function getDirectoryJs(path: string) {
|
||||
try {
|
||||
const cmd = "ls -ld -1 *.js";
|
||||
|
||||
let stdout;
|
||||
if (typeof path === "undefined") {
|
||||
({ stdout } = await child_process.exec(cmd));
|
||||
} else {
|
||||
// $FlowFixMe: Flow doesn't understand "promisify()"
|
||||
({ stdout } = await child_process.exec(cmd, { cwd: path }));
|
||||
}
|
||||
|
||||
const stdout = await child_process.exec(cmd, { cwd: path });
|
||||
console.log("OUT", path || "");
|
||||
console.log(stdout);
|
||||
} catch (e) {
|
||||
@@ -24,19 +17,12 @@ async function getDirectory(path: ?string) {
|
||||
}
|
||||
}
|
||||
|
||||
getDirectory();
|
||||
getDirectoryJs("/boot");
|
||||
/*
|
||||
OUT
|
||||
-rw-r--r-- 1 fkereki users 3336 Apr 10 13:12 dbaccess.js
|
||||
-rw-r--r-- 1 fkereki users 319 Apr 10 13:12 doroundmath.js
|
||||
-rw-r--r-- 1 fkereki users 890 Apr 10 13:12 flowcomments.js
|
||||
-rw-r--r-- 1 fkereki users 293 Apr 10 13:12 miniserver.js
|
||||
-rw-r--r-- 1 fkereki users 751 Apr 10 13:12 process_exec.js
|
||||
-rw-r--r-- 1 fkereki users 1311 Apr 10 13:12 promisify.js
|
||||
-rw-r--r-- 1 fkereki users 828 Apr 10 13:12 roundmath.js
|
||||
ERR ls: cannot access '*.js': No such file or directory
|
||||
*/
|
||||
|
||||
getDirectory("/home/fkereki/MODERNJS/chapter03/flow-typed/npm");
|
||||
getDirectoryJs("/home/fkereki/MODERNJS/chapter03/flow-typed/npm");
|
||||
/*
|
||||
OUT /home/fkereki/MODERNJS/chapter03/flow-typed/npm
|
||||
-rw-r--r-- 1 fkereki users 4791 Apr 9 12:52 axios_v0.18.x.js
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
const fs = require("fs");
|
||||
|
||||
process.on("message", obj => {
|
||||
console.log("GOT!", obj);
|
||||
|
||||
// Received a path to process
|
||||
fs
|
||||
.readdirSync(obj.path)
|
||||
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
|
||||
.filter(file => !file.startsWith("."))
|
||||
.forEach(file => {
|
||||
process.send(file);
|
||||
});
|
||||
.forEach(file => process.send(file));
|
||||
});
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
/* @flow */
|
||||
"use strict";
|
||||
|
||||
const path = require("path");
|
||||
const { spawn } = require("child_process");
|
||||
const child = spawn("node", [path.resolve("out/process_spawn_dir.js")]);
|
||||
|
||||
const filePath = "/home/fkereki";
|
||||
|
||||
child.stdin.write(filePath);
|
||||
child.stdin.write("/home/fkereki");
|
||||
|
||||
child.stdout.on("data", data => {
|
||||
console.log(String(data));
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/* @flow */
|
||||
"use strict";
|
||||
|
||||
const fs = require("fs");
|
||||
|
||||
process.stdin.resume();
|
||||
@@ -8,9 +11,7 @@ process.stdin.on("data", path => {
|
||||
.readdirSync(path)
|
||||
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
|
||||
.filter(file => !file.startsWith("."))
|
||||
.forEach(file => {
|
||||
process.stdout.write(file + "\n");
|
||||
});
|
||||
.forEach(file => process.stdout.write(file + "\n"));
|
||||
|
||||
process.stdout.end();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user