Skip to content

Commit

Permalink
Automatically create a ~/.gemrc file
Browse files Browse the repository at this point in the history
* To avoid generating documentation on `gem install`, which can take a long time.
  • Loading branch information
eregon committed Mar 30, 2020
1 parent 9c77d1b commit fb9d6fb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export async function run() {
const engineVersions = installer.getAvailableVersions(platform, engine)
const ruby = validateRubyEngineAndVersion(platform, engineVersions, engine, version)

createGemRC()

const [rubyPrefix, newPathEntries] = await installer.install(platform, ruby)

setupPath(ruby, newPathEntries)
Expand Down Expand Up @@ -82,6 +84,13 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, version)
return engine + '-' + version
}

function createGemRC() {
const gemrc = path.join(os.homedir(), '.gemrc')
if (!fs.existsSync(gemrc)) {
fs.writeFileSync(gemrc, `gem: --no-document${os.EOL}`)
}
}

function setupPath(ruby, newPathEntries) {
const originalPath = process.env['PATH'].split(path.delimiter)
let cleanPath = originalPath.filter(entry => !/\bruby\b/i.test(entry))
Expand Down
2 changes: 1 addition & 1 deletion ruby-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function getAvailableVersions(platform, engine) {

export async function install(platform, ruby) {
const rubyPrefix = await downloadAndExtract(platform, ruby)
let newPathEntries;
let newPathEntries
if (ruby.startsWith('rubinius')) {
newPathEntries = [path.join(rubyPrefix, 'bin'), path.join(rubyPrefix, 'gems', 'bin')]
} else {
Expand Down

0 comments on commit fb9d6fb

Please sign in to comment.