fix: remove debugging console log

This commit is contained in:
wancat committed 2023-10-29 17:42:31 +08:00
1 parent 40b6d3cd86
commit 917083ad30
7 files changed
+1 -23

No files matched your search

-1
View File
@@ -23,7 +23,6 @@ class SessionManager {
} }
setSession(session) { setSession(session) {
console.log('Update session:', session)
this.session.value = session this.session.value = session
this.graph.value = new FileGraph(session.graph) this.graph.value = new FileGraph(session.graph)
this.hints.value = session.hints this.hints.value = session.hints
-1
View File
@@ -42,7 +42,6 @@ describe('File', () => {
filesToCompare.forEach(({ name, path, answer }) => { filesToCompare.forEach(({ name, path, answer }) => {
test(`${name}: ${path}`, () => { test(`${name}: ${path}`, () => {
const fileToCompare = new File({ path, type: 'file', discovered: true }) const fileToCompare = new File({ path, type: 'file', discovered: true })
console.log(fileToCompare)
expect(file.contains(fileToCompare)).toBe(answer) expect(file.contains(fileToCompare)).toBe(answer)
}) })
}) })
-5
View File
@@ -30,7 +30,6 @@ describe('FileGraph', () => {
fileGraph.add(filesToAdd) fileGraph.add(filesToAdd)
console.log(fileGraph.toString())
expect(fileGraph.children.length).toBe(1) expect(fileGraph.children.length).toBe(1)
expect(fileGraph.children[0].children[0].children.length).toBe(2) expect(fileGraph.children[0].children[0].children.length).toBe(2)
}) })
@@ -76,7 +75,6 @@ describe('FileGraph', () => {
fileGraph.remove(filesToRemove) fileGraph.remove(filesToRemove)
console.log(fileGraph.toString())
expect(fileGraph.children[0].children[0].children.length).toBe(1) expect(fileGraph.children[0].children[0].children.length).toBe(1)
expect(fileGraph.children[0].children[0].children[0].name).toBe('folder1') expect(fileGraph.children[0].children[0].children[0].name).toBe('folder1')
expect(fileGraph.children[0].children[0].children[0].children.length).toBe( expect(fileGraph.children[0].children[0].children[0].children.length).toBe(
@@ -110,7 +108,6 @@ describe('FileGraph', () => {
] ]
fileGraph.discover(discoverFiles) fileGraph.discover(discoverFiles)
console.log(fileGraph.toString())
expect(fileGraph.children[0].children[0].children[0].children.length).toBe( expect(fileGraph.children[0].children[0].children[0].children.length).toBe(
3 3
) )
@@ -143,7 +140,6 @@ describe('FileGraph', () => {
] ]
fileGraph.add(filesToAdd) fileGraph.add(filesToAdd)
console.log(fileGraph.toString())
const newFiles = [ const newFiles = [
{ {
@@ -170,7 +166,6 @@ describe('FileGraph', () => {
fileGraph.discover(newFiles) fileGraph.discover(newFiles)
console.log(fileGraph.toString())
expect(fileGraph.children[0].children[0].children.length).toBe(2) expect(fileGraph.children[0].children[0].children.length).toBe(2)
expect(fileGraph.children[0].children[0].children[0].children.length).toBe( expect(fileGraph.children[0].children[0].children[0].children.length).toBe(
3 3
-9
View File
@@ -12,14 +12,8 @@ function mergeTest(files1, files2, expectedFiles) {
const node2 = createNodeFromFiles(files2) const node2 = createNodeFromFiles(files2)
const expectedNode = createNodeFromFiles(expectedFiles) const expectedNode = createNodeFromFiles(expectedFiles)
console.log('node1', node1.toString())
console.log('node2', node2.toString())
console.log('expected', expectedNode.toString())
node1.merge(node2) node1.merge(node2)
console.log('after-merged', node1.toString())
expect(node1.toString()).toBe(expectedNode.toString()) expect(node1.toString()).toBe(expectedNode.toString())
} }
@@ -103,7 +97,6 @@ describe('FileNode', () => {
expect(rootNode.children.length).toBe(2) expect(rootNode.children.length).toBe(2)
expect(rootNode.children[1].children.length).toBe(1) expect(rootNode.children[1].children.length).toBe(1)
console.log(rootNode.toString())
}) })
test('adds nested children to the tree with makeParents option', () => { test('adds nested children to the tree with makeParents option', () => {
@@ -116,7 +109,6 @@ describe('FileNode', () => {
rootNode.addChild(file, { makeParents: true }) rootNode.addChild(file, { makeParents: true })
console.log(rootNode.toString())
let currentNode = rootNode let currentNode = rootNode
for (let i = 0; i < 5; i += 1) { for (let i = 0; i < 5; i += 1) {
expect(currentNode.children.length).toBe(1) expect(currentNode.children.length).toBe(1)
@@ -279,7 +271,6 @@ test('load nested fileNode', () => {
const node = new FileNode(data) const node = new FileNode(data)
console.log(node.toString())
expect(node.children.length).toBe(2) expect(node.children.length).toBe(2)
expect(node.children[1].children.length).toBe(1) expect(node.children[1].children.length).toBe(1)
expect(node.children[1].children[0].children.length).toBe(1) expect(node.children[1].children[0].children.length).toBe(1)
@@ -5,7 +5,6 @@ import { pushToSession } from '../socket.js'
const commandCompleteCallbacks = new Map() const commandCompleteCallbacks = new Map()
export async function newCommand(req, res) { export async function newCommand(req, res) {
console.log('new command:', req.body)
const { command, pwd, output, error, ...additionalData } = req.body const { command, pwd, output, error, ...additionalData } = req.body
if (!command) { if (!command) {
+1 -5
View File
@@ -10,16 +10,12 @@ function sanitizeId(id) {
export function checkFile(id, file) { export function checkFile(id, file) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const cmd = buildFileCheckCmd(file) const cmd = buildFileCheckCmd(file)
console.log(cmd)
// WARNING: This is vulnerable to command injection // WARNING: This is vulnerable to command injection
execFile( execFile(
'docker', 'docker',
['exec', sanitizeId(id), ...cmd], ['exec', sanitizeId(id), ...cmd],
{ timeout: 1000 }, { timeout: 1000 },
(error, stdout, stderr) => { (error) => {
if (stderr) console.log('error', error)
if (stdout) console.log('stdout', stdout)
if (error) console.log('error', error)
const exists = !error const exists = !error
if (exists === file.exists) { if (exists === file.exists) {
resolve(true) resolve(true)
-1
View File
@@ -72,7 +72,6 @@ export default class CommandHandler extends SessionHandler {
if (files.length === 0) { if (files.length === 0) {
return true return true
} }
console.log('checkFiles', files)
try { try {
const checks = await Promise.all( const checks = await Promise.all(
files.map((f) => checkFile(this.session.containerId, f)) files.map((f) => checkFile(this.session.containerId, f))