add LOG env option
This commit is contained in:
parent
e39cd2c9cd
commit
3e66e1ee93
1 changed files with 5 additions and 3 deletions
|
|
@ -7,6 +7,8 @@ import http from 'http';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
|
||||||
|
const LOG = !!process.env.LOG || false;
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
cowsay.say({
|
cowsay.say({
|
||||||
text: 'welcome to @strudel/sampler',
|
text: 'welcome to @strudel/sampler',
|
||||||
|
|
@ -22,7 +24,7 @@ async function getFilesInDirectory(directory) {
|
||||||
const fullPath = join(directory, dirent.name);
|
const fullPath = join(directory, dirent.name);
|
||||||
if (dirent.isDirectory()) {
|
if (dirent.isDirectory()) {
|
||||||
if (dirent.name.startsWith('.')) {
|
if (dirent.name.startsWith('.')) {
|
||||||
console.warn(`ignore hidden folder: ${fullPath}`);
|
LOG && console.warn(`ignore hidden folder: ${fullPath}`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
@ -30,9 +32,9 @@ async function getFilesInDirectory(directory) {
|
||||||
['wav', 'mp3', 'ogg'].includes(f.split('.').slice(-1)[0].toLowerCase()),
|
['wav', 'mp3', 'ogg'].includes(f.split('.').slice(-1)[0].toLowerCase()),
|
||||||
);
|
);
|
||||||
files = files.concat(subFiles);
|
files = files.concat(subFiles);
|
||||||
console.log(`${dirent.name} (${subFiles.length})`);
|
LOG && console.log(`${dirent.name} (${subFiles.length})`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn(`skipped due to error: ${fullPath}`);
|
LOG && console.warn(`skipped due to error: ${fullPath}`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
files.push(fullPath);
|
files.push(fullPath);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue