export NODE_PATH="$(npm config get prefix)/lib/node_modules"
brew install libgcrypt
Last active
December 3, 2018 19:00
-
-
Save sirgalleto/d0e3ea69c37d96298222e66b2901b697 to your computer and use it in GitHub Desktop.
PRs vemos rolas no sabemos scripts
This file contains hidden or 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
#!/usr/bin/env node | |
const fs = require('fs') | |
const spotify = require('spotify-node-applescript') | |
const message = fs.readFileSync(process.argv[2], { encoding: 'utf8' }) | |
spotify.getTrack((err, track) => { | |
const trackData = formatTrackData(track) | |
fs.writeFileSync(process.argv[2], `${message}\n${trackData}`) | |
process.exit(0) | |
}) | |
function formatTrackData(track) { | |
return [ | |
'MUSIC_SOURCE=spotify', | |
`TRACK_NAME=${track.name}`, | |
`ARTIST_NAME=${track.album_artist}`, | |
`SPOTIFY_URL=${track.spotify_url}`, | |
`SPOTIFY_ID=${track.id}`, | |
].join('\n') | |
} |
This file contains hidden or 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
const { Signature, Repository, Note } = require("nodegit"); | |
async function start() { | |
const repository = await Repository.open('./'); | |
const commit = await repository.getBranchCommit('master'); | |
const oid = commit.id(); | |
const author = Signature.create('Sebastián Osorio', '[email protected]', Date.now(), 0); | |
const noteString = 'THIS NOTE SHOULD INCLUDES MUSIC!' | |
const note = await Note.create(repository, 'refs/notes/commits', author, author, oid, noteString, 1) | |
console.log('TCL: start -> note', note) | |
} | |
start() |
This file contains hidden or 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
#!/usr/bin/env node | |
console.log('This is a post commit') | |
console.log(process.argv) |
This file contains hidden or 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
#!/usr/bin/env node | |
const spotify = require("spotify-node-applescript"); | |
const { Signature, Repository, Note } = require('nodegit'); | |
async function createNote(track) { | |
try { | |
const repository = await Repository.open('./'); | |
const commit = await repository.getBranchCommit('master'); | |
const oid = commit.id(); | |
const trackMessage = formatTrackData(track) | |
const author = Signature.create('Sebastián Osorio', '[email protected]', Date.now(), 0); | |
await Note.create(repository, 'refs/notes/commits', author, author, oid, trackMessage, 1) | |
} catch(error) { | |
console.error('There was an error adding the music note:', error) | |
process.exit(1) | |
} | |
process.exit(0); | |
} | |
function formatTrackData(track) { | |
return [ | |
"MUSIC_SOURCE=spotify", | |
`TRACK_NAME=${track.name}`, | |
`ARTIST_NAME=${track.album_artist}`, | |
`SPOTIFY_URL=${track.spotify_url}`, | |
`SPOTIFY_ID=${track.id}` | |
].join("\n"); | |
} | |
spotify.getTrack((err, track) => { | |
if(err) { | |
console.error('There was an error getting the current song:', err) | |
process.exit(1) | |
} | |
createNote(track) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment