-
-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
747 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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"); | ||
|
||
module.exports = async (job, settings, { input, output, type = "dir" }, actionType) => { | ||
if (!input) { | ||
throw new Error("No input path provided"); | ||
} | ||
|
||
if (!output) { | ||
throw new Error("No output path provided"); | ||
} | ||
|
||
/* fill absolute/relative paths */ | ||
if (!path.isAbsolute(input)) input = path.join(job.workpath, input); | ||
if (!path.isAbsolute(output)) output = path.join(job.workpath, output); | ||
|
||
/* create parent directories if needed */ | ||
fs.mkdirSync(path.dirname(output), { recursive: true }); | ||
|
||
/* remove existing link if it exists */ | ||
if (fs.existsSync(output)) { | ||
fs.unlinkSync(output); | ||
} | ||
|
||
settings.logger.log(`[${job.uid}] creating symbolic link from ${input} to ${output}...`); | ||
|
||
/* create symbolic link */ | ||
try { | ||
fs.symlinkSync(input, output, type); | ||
} catch (err) { | ||
throw new Error(`Failed to create symbolic link: ${err.message}`); | ||
} | ||
|
||
return job; | ||
}; |
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,10 @@ | ||
{ | ||
"name": "@nexrender/action-link", | ||
"homepage": "https://www.nexrender.com", | ||
"author": "inlife", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
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,39 @@ | ||
# Action: Link | ||
|
||
Create symbolic links between files or directories. | ||
|
||
## Information | ||
|
||
* `input` required argument, source path for the symbolic link, can be either relative or absolute path | ||
* `output` required argument, destination path where the symbolic link will be created, can be either relative or absolute path | ||
* `type` optional argument, type of symbolic link to create: | ||
* `dir` - Create a directory symbolic link (default) | ||
* `file` - Create a file symbolic link | ||
* `junction` - Create a directory junction (Windows only) | ||
|
||
The action will: | ||
1. Create any necessary parent directories for the output path | ||
2. Remove any existing symbolic link at the output path | ||
3. Create a new symbolic link from input to output | ||
|
||
Note: Creating symbolic links may require elevated permissions on some systems. | ||
|
||
## Usage | ||
|
||
```json | ||
{ | ||
"actions": { | ||
"prerender": [ | ||
{ | ||
"module": "@nexrender/action-link", | ||
"input": "source/large-file.mp4", | ||
"output": "assets/linked-file.mp4" | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
|
||
## License | ||
|
||
Please refer to the [LICENSE](LICENSE) file for more information. Unlike the main nexrender project, this plugin is licensed under the AGPL-3.0 license. |
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