
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
@lennym/commit
Advanced tools
API for committing file changes to github
To write content to a file on the default branch:
const Git = require('@lennym/commit');
const git = Git({
repo: 'lennym/test-repo',
token: 'YOUR_GITHUB_ACCESS_TOKEN'
});
git
.add('file.txt', 'File content')
.commit('Set file content')
.push()
.then(() => console.log('All done'));
To write to a branch other than the default branch for the repo:
const git = Git({
repo: 'lennym/test-repo',
token: '...',
branch: 'development'
});
git
.add('file.txt', 'File content')
.commit('Set file content')
.push()
.then(() => console.log('All done'));
To create a new branch:
const git = Git({
repo: 'lennym/test-repo',
token: '...'
});
git
.branch('my-new-branch')
.add('file.txt', 'File content')
.commit('Set file content')
.push()
.then(() => console.log('All done'));
To update multiple files in one commit:
const git = Git({
repo: 'lennym/test-repo',
token: '...'
});
git
.add('file1.txt', 'File 1 content')
.add('file2.txt', 'File 2 content')
.commit('Set multiple file content')
.push()
.then(() => console.log('All done'));
To update multiple files in multiple commits:
const git = Git({
repo: 'lennym/test-repo',
token: '...'
});
git
.add('file1.txt', 'File 1 content')
.commit('Update file 1')
.add('file2.txt', 'File 2 content')
.commit('Update file 2')
.push()
.then(() => console.log('All done'));
To add a non-text file, pass a Buffer
instead of a string to add
:
const img = fs.readFileSync('./some-image.png');
const git = Git({
repo: 'lennym/test-repo',
token: '...'
});
git
.add('image.png', img)
.commit('Add image file')
.push()
.then(() => console.log('All done'));
const git = Git({
repo: 'lennym/test-repo',
token: '...'
});
git.head()
.then(sha => console.log(sha));
FAQs
Simple API for committing file changes to github
The npm package @lennym/commit receives a total of 105 weekly downloads. As such, @lennym/commit popularity was classified as not popular.
We found that @lennym/commit demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.