fix: add dart-sass to PATH
This commit is contained in:
parent
07d6db952e
commit
47b2964798
5 changed files with 56 additions and 17 deletions
32
__tests__/dart-sass.test.ts
Normal file
32
__tests__/dart-sass.test.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
import fs from 'node:fs'
|
||||
import path from 'path'
|
||||
import os from 'node:os'
|
||||
import { OctokitReleaseLookup } from '../src/asset-lookup'
|
||||
import { Platform } from '../src/os'
|
||||
import { DartSassInstaller } from '../src/dart-sass'
|
||||
|
||||
let tmpDir = ''
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetModules()
|
||||
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'setup-hugo-'))
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
fs.rmSync(tmpDir, { recursive: true })
|
||||
})
|
||||
|
||||
describe('Install dart-sass', () => {
|
||||
test('Download latest dart-sass', async () => {
|
||||
const releaseLookup = new OctokitReleaseLookup()
|
||||
const platformMock = new Platform('linux', undefined, { HOME: tmpDir })
|
||||
const dartSassInstaller = new DartSassInstaller(releaseLookup, platformMock)
|
||||
|
||||
expect(
|
||||
async () =>
|
||||
await dartSassInstaller.install({
|
||||
version: 'latest'
|
||||
})
|
||||
).not.toThrow()
|
||||
})
|
||||
})
|
17
dist/index.js
vendored
17
dist/index.js
vendored
|
@ -49450,12 +49450,9 @@ class HugoInstaller {
|
|||
try {
|
||||
const cachedTool = tool_cache.find(Hugo.Name, release.tag_name, this.platform.arch);
|
||||
if (cachedTool) {
|
||||
await (0,io.cp)(cachedTool, external_path_default().join(binDir, hugoBinName));
|
||||
core.addPath(cachedTool);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
core.info('Tool not present in cache - downloading it...');
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
core.warning(`Failed to lookup tool in cache: ${errorMsg(e)}`);
|
||||
|
@ -49555,8 +49552,8 @@ class OctokitReleaseLookup {
|
|||
class DartSassInstaller {
|
||||
releaseLookup;
|
||||
platform;
|
||||
constructor(releaseLookup) {
|
||||
this.platform = new Platform();
|
||||
constructor(releaseLookup, platform) {
|
||||
this.platform = platform ?? new Platform();
|
||||
this.releaseLookup = releaseLookup;
|
||||
}
|
||||
async install(cmd) {
|
||||
|
@ -49567,8 +49564,11 @@ class DartSassInstaller {
|
|||
const binDir = await this.platform.ensureBinDir(workDir);
|
||||
const tmpDir = external_node_os_namespaceObject.tmpdir();
|
||||
try {
|
||||
core.addPath(tool_cache.find(DartSass.Name, release.tag_name, this.platform.arch));
|
||||
return;
|
||||
const cachedDartSass = tool_cache.find(DartSass.Name, release.tag_name, this.platform.arch);
|
||||
if (cachedDartSass) {
|
||||
core.addPath(cachedDartSass);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
core.warning(`Failed to lookup cached version: ${errorMsg(e)}`);
|
||||
|
@ -49595,6 +49595,7 @@ class DartSassInstaller {
|
|||
}
|
||||
catch (e) {
|
||||
core.warning(`Failed to cache dart-sass directory: ${errorMsg(e)}`);
|
||||
core.addPath(external_path_default().join(binDir, 'dart-sass'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
@ -18,8 +18,8 @@ export class DartSassInstaller {
|
|||
private readonly releaseLookup: IReleaseLookup
|
||||
private readonly platform: Platform
|
||||
|
||||
constructor(releaseLookup: IReleaseLookup) {
|
||||
this.platform = new Platform()
|
||||
constructor(releaseLookup: IReleaseLookup, platform?: Platform) {
|
||||
this.platform = platform ?? new Platform()
|
||||
this.releaseLookup = releaseLookup
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,15 @@ export class DartSassInstaller {
|
|||
const tmpDir = os.tmpdir()
|
||||
|
||||
try {
|
||||
core.addPath(tc.find(DartSass.Name, release.tag_name, this.platform.arch))
|
||||
return
|
||||
const cachedDartSass = tc.find(
|
||||
DartSass.Name,
|
||||
release.tag_name,
|
||||
this.platform.arch
|
||||
)
|
||||
if (cachedDartSass) {
|
||||
core.addPath(cachedDartSass)
|
||||
return
|
||||
}
|
||||
} catch (e) {
|
||||
core.warning(`Failed to lookup cached version: ${errorMsg(e)}`)
|
||||
}
|
||||
|
@ -82,6 +89,7 @@ export class DartSassInstaller {
|
|||
)
|
||||
} catch (e) {
|
||||
core.warning(`Failed to cache dart-sass directory: ${errorMsg(e)}`)
|
||||
core.addPath(path.join(binDir, 'dart-sass'))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import { components } from '@octokit/openapi-types'
|
|||
import * as tc from '@actions/tool-cache'
|
||||
import path from 'path'
|
||||
import * as os from 'node:os'
|
||||
import { mv, rmRF, cp } from '@actions/io'
|
||||
import { mv, rmRF } from '@actions/io'
|
||||
import { randomUUID } from 'crypto'
|
||||
import { errorMsg } from './utils/error'
|
||||
|
||||
|
@ -48,10 +48,8 @@ export class HugoInstaller {
|
|||
this.platform.arch
|
||||
)
|
||||
if (cachedTool) {
|
||||
await cp(cachedTool, path.join(binDir, hugoBinName))
|
||||
core.addPath(cachedTool)
|
||||
return
|
||||
} else {
|
||||
core.info('Tool not present in cache - downloading it...')
|
||||
}
|
||||
} catch (e) {
|
||||
core.warning(`Failed to lookup tool in cache: ${errorMsg(e)}`)
|
||||
|
|
Loading…
Reference in a new issue