buildkit(config): rename methods
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -45,7 +45,7 @@ afterEach(() => {
|
|||||||
rimraf.sync(tmpDir);
|
rimraf.sync(tmpDir);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('generate', () => {
|
describe('resolve', () => {
|
||||||
test.each([
|
test.each([
|
||||||
['debug = true', false, 'debug = true', null],
|
['debug = true', false, 'debug = true', null],
|
||||||
[`notfound.toml`, true, '', new Error('config file notfound.toml not found')],
|
[`notfound.toml`, true, '', new Error('config file notfound.toml not found')],
|
||||||
@@ -65,9 +65,9 @@ describe('generate', () => {
|
|||||||
});
|
});
|
||||||
let config: string;
|
let config: string;
|
||||||
if (file) {
|
if (file) {
|
||||||
config = buildkit.config.generateFromFile(val);
|
config = buildkit.config.resolveFromFile(val);
|
||||||
} else {
|
} else {
|
||||||
config = buildkit.config.generateFromString(val);
|
config = buildkit.config.resolveFromString(val);
|
||||||
}
|
}
|
||||||
expect(config).toEqual(tmpName);
|
expect(config).toEqual(tmpName);
|
||||||
const configValue = fs.readFileSync(tmpName, 'utf-8');
|
const configValue = fs.readFileSync(tmpName, 'utf-8');
|
||||||
|
|||||||
@@ -25,15 +25,15 @@ export class Config {
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public generateFromString(s: string): string {
|
public resolveFromString(s: string): string {
|
||||||
return this.generate(s, false);
|
return this.resolve(s, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public generateFromFile(s: string): string {
|
public resolveFromFile(s: string): string {
|
||||||
return this.generate(s, true);
|
return this.resolve(s, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private generate(s: string, file: boolean): string {
|
private resolve(s: string, file: boolean): string {
|
||||||
if (file) {
|
if (file) {
|
||||||
if (!fs.existsSync(s)) {
|
if (!fs.existsSync(s)) {
|
||||||
throw new Error(`config file ${s} not found`);
|
throw new Error(`config file ${s} not found`);
|
||||||
|
|||||||
Reference in New Issue
Block a user