Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create shelljs.js #90

Merged
merged 2 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions npm_Modules/ShellJs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## ShellJs Module

`ShellJS` is an npm module that provides portable Unix shell commands for `Node.js`. It allows you to execute shell commands within your Node.js applications,
making it easier to interact with the file system, run scripts, and perform other command-line operations.

# Installation

Here '-g' is used for a global installation
```
$ npm install [-g] shelljs
```

# Features:

- ShellJS is a portable implementation of Unix shell commands that can be used on Windows, Linux, and macOS.
- It is built on top of the Node.js API, providing a convenient way to execute shell commands using JavaScript
- With ShellJS, you can perform common shell operations such as copying files, moving files, deleting files, creating directories, and running shell scripts.
- It provides a simple and intuitive API that mimics the behavior of popular Unix shell commands, making it easy to write cross-platform scripts.
- ShellJS is widely used in Node.js projects for automating tasks, building scripts, and managing file operations.
- It offers a range of features, including globbing patterns for file matching, piping commands, and handling command output.
25 changes: 25 additions & 0 deletions npm_Modules/ShellJs/shelljs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var shell = require('shelljs');

if (!shell.which('git')) {
shell.echo('Sorry, this script requires git');
shell.exit(1);
}

// Copy files to release dir
shell.rm('-rf', 'out/Release');
shell.cp('-R', 'stuff/', 'out/Release');

// Replace macros in each .js file
shell.cd('lib');
shell.ls('*.js').forEach(function (file) {
shell.sed('-i', 'BUILD_VERSION', 'v0.1.2', file);
shell.sed('-i', /^.*REMOVE_THIS_LINE.*$/, '', file);
shell.sed('-i', /.*REPLACE_LINE_WITH_MACRO.*\n/, shell.cat('macro.js'), file);
});
shell.cd('..');

// Run external tool synchronously
if (shell.exec('git commit -am "Auto-commit"').code !== 0) {
shell.echo('Error: Git commit failed');
shell.exit(1);
}