generated from expressots/expressots-project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from expressots/feature/global-base-route-path
Feature/global base route path
- Loading branch information
Showing
7 changed files
with
132 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
|
||
function copyRecursiveSync(src, dest) { | ||
const exists = fs.existsSync(src); | ||
const stats = exists && fs.statSync(src); | ||
const isDirectory = exists && stats.isDirectory(); | ||
|
||
if (isDirectory) { | ||
fs.mkdirSync(dest); | ||
fs.readdirSync(src).forEach(function (childItemName) { | ||
copyRecursiveSync( | ||
path.join(src, childItemName), | ||
path.join(dest, childItemName), | ||
); | ||
}); | ||
} else { | ||
fs.copyFileSync(src, dest); | ||
} | ||
} | ||
|
||
if (process.argv.length < 4) { | ||
process.stderr.write( | ||
"Usage: node copy.js <origin1> <origin2> ... <destination>\n", | ||
); | ||
process.exit(1); | ||
} | ||
|
||
const destination = process.argv[process.argv.length - 1]; | ||
|
||
for (let i = 2; i < process.argv.length - 1; i++) { | ||
const origin = process.argv[i]; | ||
copyRecursiveSync(origin, path.join(destination, path.basename(origin))); | ||
process.stdout.write(`Copied: ${origin} to ${destination}\n`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const fs = require("fs").promises; | ||
|
||
const moveFile = async (origin, destination) => { | ||
try { | ||
await fs.access(origin); | ||
} catch (error) { | ||
process.stderr.write(`Error: Origin '${origin}' not found\n`); | ||
process.exit(1); | ||
} | ||
|
||
try { | ||
await fs.rename(origin, destination); | ||
process.stdout.write(`Move: ${origin} to ${destination}\n`); | ||
} catch (error) { | ||
process.stderr.write( | ||
`Error: Unable to move '${origin}' to '${destination}'\n`, | ||
); | ||
process.exit(1); | ||
} | ||
}; | ||
|
||
if (process.argv.length !== 4) { | ||
process.stderr.write("Usage: node mv.js <origin> <destination>\n"); | ||
process.exit(1); | ||
} | ||
|
||
const origin = process.argv[2]; | ||
const destination = process.argv[3]; | ||
|
||
moveFile(origin, destination); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const fs = require("fs").promises; | ||
|
||
const removeTarget = async (target) => { | ||
try { | ||
await fs.rm(target, { recursive: true, force: true }); | ||
process.stdout.write(`Removed: ${target}\n`); | ||
} catch (error) { | ||
process.stderr.write(`Error: Unable to remove '${target}'\n`); | ||
process.exit(1); | ||
} | ||
}; | ||
|
||
if (process.argv.length !== 3) { | ||
process.stderr.write("Usage: node rm.js <dir/file>\n"); | ||
process.exit(1); | ||
} | ||
|
||
const target = process.argv[2]; | ||
removeTarget(target); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.