Skip to content

Commit 34a4822

Browse files
committed
save
1 parent ee5fb91 commit 34a4822

9 files changed

+633
-858
lines changed

.github/workflows/npm-publish.yml

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ concurrency: ${{ github.workflow }}
77
jobs:
88
npm-publish:
99
runs-on: windows-latest
10+
defaults:
11+
run:
12+
shell: bash
1013
steps:
1114
- uses: actions/checkout@v4
1215
- uses: actions/setup-node@v4

.github/workflows/npm-test.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
node-version: ["18", "20"]
18+
node-version: ["18", "20", "22"]
1919
runs-on: windows-latest
20+
defaults:
21+
run:
22+
shell: bash
2023
steps:
2124
- uses: actions/checkout@v4
2225
- uses: actions/setup-node@v4

LICENSE

+28-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
1-
GNU GENERAL PUBLIC LICENSE
2-
Version 2, June 1991
1+
2+
Note that the only valid version of the GPL as far as this project
3+
is concerned is _this_ particular version of the license (ie v2, not
4+
v2.2 or v3.x or whatever), unless explicitly otherwise stated.
5+
6+
HOWEVER, in order to allow a migration to GPLv3 if that seems like
7+
a good idea, I also ask that people involved with the project make
8+
their preferences known. In particular, if you trust me to make that
9+
decision, you might note so in your copyright message, ie something
10+
like
11+
12+
This file is licensed under the GPL v2, or a later version
13+
at the discretion of Linus.
14+
15+
might avoid issues. But we can also just decide to synchronize and
16+
contact all copyright holders on record if/when the occasion arises.
17+
18+
Linus Torvalds
19+
20+
----------------------------------------
21+
22+
GNU GENERAL PUBLIC LICENSE
23+
Version 2, June 1991
324

425
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
526
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
627
Everyone is permitted to copy and distribute verbatim copies
728
of this license document, but changing it is not allowed.
829

9-
Preamble
30+
Preamble
1031

1132
The licenses for most software are designed to take away your
1233
freedom to share and change it. By contrast, the GNU General Public
@@ -56,7 +77,7 @@ patent must be licensed for everyone's free use or not licensed at all.
5677
The precise terms and conditions for copying, distribution and
5778
modification follow.
5879

59-
GNU GENERAL PUBLIC LICENSE
80+
GNU GENERAL PUBLIC LICENSE
6081
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
6182

6283
0. This License applies to any program or other work which contains
@@ -255,7 +276,7 @@ make exceptions for this. Our decision will be guided by the two goals
255276
of preserving the free status of all derivatives of our free software and
256277
of promoting the sharing and reuse of software generally.
257278

258-
NO WARRANTY
279+
NO WARRANTY
259280

260281
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261282
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
@@ -277,9 +298,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277298
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278299
POSSIBILITY OF SUCH DAMAGES.
279300

280-
END OF TERMS AND CONDITIONS
301+
END OF TERMS AND CONDITIONS
281302

282-
How to Apply These Terms to Your New Programs
303+
How to Apply These Terms to Your New Programs
283304

284305
If you develop a new program, and you want it to be of the greatest
285306
possible use to the public, the best way to achieve this is to make it

PortableGit-64-bit.7z.exe

5.33 KB
Binary file not shown.

README.md

+13-6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ You can install this package using npm or your favorite npm package manager. If
3535
npm install --save-dev portablegit
3636
```
3737

38+
<sup>This package has a `postinstall` script</sup>
39+
3840
⚠️ **It's not recommended to install this package globally!** [Install Git for Windows normally](https://gitforwindows.org/) on your system instead. Interested in installing Git globally on more that just Windows machines? Check out [Git - Installing Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
3941

4042
🛑 Only works on Windows x64 systems. Does not work on macOS or Linux.
@@ -62,24 +64,29 @@ Available binary commands exposed through this npm package are:
6264
- **`git-cmd`:** Starts a `cmd.exe` subshell preloaded with `git.exe` and other things in `$PATH`. Does **not** launch a new window.
6365
- **`git-gui`:** Starts [the Git GUI](https://git-scm.com/docs/git-gui).
6466
- **`gitk`:** Starts [the GitK GUI](https://git-scm.com/docs/gitk/).
67+
- `tig`, `start-ssh-agent`, `start-ssh-pagent`, `scalar`, `git-receive-pack` `git-upload-pack`: Extra things that I'm not not smart enough to understand.
68+
69+
This `portablegit` npm package is versioned to follow Git for Windows. For example, Git for Windows releases `v2.45.1.windows.1` (derived from Git 2.45.1) which this `portablegit` package releases as `2.45.11`. Note that there's a `1` suffix appended to the version number. Git for Windows `v2.45.1.windows.2` would then be released as `[email protected]` on npm. For `X.Y.0.windows.1` releases the npm-ified `X.Y.01` version specifier is invalid. We need to drop the leading zero to create an `X.Y.1` release.
6570

6671
You can `import.meta.resolve()` or `require.resolve()` anything that would normally be in the extracted `PortableGit/*` folder. Here's an example:
6772

6873
```js
69-
const cat = import.meta.resolve("portablegit/usr/bin/cat.exe");
74+
const cat = import.meta.resolve("portablegit/usr/bin/cat");
7075
console.log(cat);
71-
//=> 'file:///C:/Users/you/Documents/myproject/node_modules/portablegit/out/portablegit/usr/bin/cat.exe'
76+
//=> 'file:///C:/myproject/node_modules/portablegit/out/portablegit/usr/bin/cat'
7277

73-
const cut = require.resolve("portablegit/usr/bin/cut.exe");
78+
const cut = require.resolve("portablegit/usr/bin/cut");
7479
console.log(cut);
75-
//=> 'C:\\Users\\you\\Documents\\myproject\\node_modules\\portablegit\\out\\portablegit\\usr\\bin\\cut.exe'
80+
//=> 'C:\\myproject\\node_modules\\portablegit\\out\\portablegit\\usr\\bin\\cut'
7681
```
7782

78-
This can be useful if you need to resolve the path to a specific binary (`cat.exe`, `cut.exe`, etc.) that isn't exposed by default.
83+
This can be useful if you need to resolve the path to a specific binary (`cat.exe`, `cut.exe`, etc.) that isn't exposed by default. Note that you don't need to use the `.exe` suffix since Windows will helpfully add `.exe` when attempting to run the file.
7984

8085
## Development
8186

8287
![Node.js](https://img.shields.io/static/v1?style=for-the-badge&message=Node.js&color=339933&logo=Node.js&logoColor=FFFFFF&label=)
8388
![GitHub Actions](https://img.shields.io/static/v1?style=for-the-badge&message=GitHub+Actions&color=2088FF&logo=GitHub+Actions&logoColor=FFFFFF&label=)
8489

85-
You'll need a Windows computer to test this package locally. You can run `npm run build` to make sure everything looks good locally. `npm run generate` will check for a new Git for Windows PortableGit release and download it if it exists. Make sure you do this manually on each new Git for Windows release. You can subscribe to releases on the [git-for-windows/git](https://github.com/git-for-windows/git) repository.
90+
You'll need a Windows computer to test this package locally. You can run `npm run build` to make sure everything looks good locally. `npm run generate` redownloads the configured version of Git for Windows PortableGit as a 7zip self-extracting archive.
91+
92+
Each new upcoming release will first be tried as a prerelease `-rc.N` first to make sure that everything is 99% guarenteed to work when autopublishing.

index.test.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import test from "node:test";
2+
import assert from "node:assert/strict";
3+
import { $ } from "execa";
4+
import { readFile } from "node:fs/promises";
5+
const package_ = JSON.parse(
6+
await readFile(new URL(import.meta.resolve("./package.json")), "utf8"),
7+
);
8+
9+
await $({ stdio: "inherit" })`npm run build`;
10+
// simulate postinstall
11+
await $({
12+
cwd: "out",
13+
stdio: "inherit",
14+
reject: false,
15+
})`post-install.bat`;
16+
17+
test("git", async () => {
18+
await $({ stdio: "inherit" })`${package_.bin.git} --version`;
19+
});
20+
21+
test("bash", async () => {
22+
await $({ stdio: "inherit" })`${package_.bin.bash} --version`;
23+
});
24+
25+
test("import.meta.resolve()", () => {
26+
console.log(import.meta.resolve("portablegit/usr/bin/cat"))
27+
console.log(import.meta.resolve("portablegit/usr/bin/cat.exe"))
28+
})

0 commit comments

Comments
 (0)