-
-
Notifications
You must be signed in to change notification settings - Fork 763
Closed as duplicate
Description
Description
Cross-platform file operations like cp, mv, mkdir are inconsistent between Unix and Windows systems. This forces us to either:
- Write platform-specific shell commands
- Use external tools like
shxorcross-env - Implement annoying conditional logic in taskfiles
This creates maintenance overhead and reduces portability of Taskfiles.
Proposal
Add native file system operations implemented in Go, using the fs: prefix to distinguish them from shell commands:
Core Operations
fs:copy- Copy files or directories with recursive supportfs:move- Move/rename files or directoriesfs:mkdir- Create directories (with parent creation support)fs:remove- Remove files or directoriesfs:exists- Check if file/directory exists (useful for conditionals)fs:chmod- Change file permissions (Unix-style, no-op on Windows)
Benefits
- True cross-platform compatibility - No need for platform-specific commands
- Consistent behavior - Same semantics across Windows, macOS, and Linux
- No external dependencies - Everything built into Task itself
- Familiar syntax - Mirrors common shell operations developers already know
Backwards Compatibility
If a task with the same name (e.g., fs:copy) exists in the taskfile, it overrides the built-in command, preserving existing functionality.
Usage Examples
Task-based Syntax
build:
cmds:
- go build -o ./bin/app
- task: fs:copy
vars:
SRC: ./bin/app
DEST: ./dist/app
RECURSIVE: true
- task: fs:mkdir
vars:
DIR: ./dist/config
PARENTS: trueInline Syntax (Alternative)
build:
cmds:
- go build -o ./bin/app
- fs:copy ./bin/app ./dist/app
- fs:mkdir -p ./dist/config
- fs:remove ./temp/*Error Handling
safe-copy:
cmds:
- task: fs:copy
vars:
SRC: ./source
DEST: ./backup
FAIL_FAST: true
PRESERVE_PERMISSIONS: trueMetadata
Metadata
Assignees
Labels
No labels