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

Adding headers to an already existing file #120

Open
aminya opened this issue May 11, 2022 · 1 comment
Open

Adding headers to an already existing file #120

aminya opened this issue May 11, 2022 · 1 comment
Assignees

Comments

@aminya
Copy link

aminya commented May 11, 2022

I use the Parcel bundler to generate my built script. It would be nice if we could prepend the header to this generated file (by specifying the path).

@Oaphi Oaphi self-assigned this May 11, 2022
@Oaphi
Copy link
Member

Oaphi commented May 11, 2022

Agreed, that's already planned - for now, we've been using the following simple shell script to prepend the headers:

#!/bin/bash

dist="dist"
output=$dist"/headers.js"

generate-headers tampermonkey \
    -o $output \
    -m all meta \
    -g get set delete unsafe \
    --collapse \
    --pretty

# given the output is "dist/something.js" and the metadata file is "dist/headers.js"
userscript="$(find -iwholename "./$dist/*\.js" -type f -not -iname "*headers\.js")"

sed -i -e "{1e cat $output; echo; echo" -e "; N}" $userscript

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

No branches or pull requests

2 participants