Skip to content

Commit

Permalink
Merge pull request #8 from rvanasa/refactor-part-identifier
Browse files Browse the repository at this point in the history
Refactor generated identifiers
  • Loading branch information
rvanasa authored May 28, 2024
2 parents 46f8338 + 2c1a844 commit 8fee2cd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { mkdirp } from 'mkdirp';
import { join, resolve } from 'path';
import copy from 'recursive-copy';
import { rimraf } from 'rimraf';
import { Config } from './config.js';
import { Config, RustDependency } from './config.js';
import { exists, moduleRelative } from './util.js';
import chalk from 'chalk';

Expand Down Expand Up @@ -39,6 +39,8 @@ const replaceInFile = async (
await writeFile(path, content);
};

const getPartIdentifier = (part: RustDependency, i: number) => `part_${i}`;

export const generate = async (config: Config): Promise<string[]> => {
const changes = [];

Expand Down Expand Up @@ -162,7 +164,7 @@ export const generate = async (config: Config): Promise<string[]> => {
.map((part, i) =>
TOML.stringify({
dependencies: {
[`part_${i}`]:
[getPartIdentifier(part, i)]:
typeof part === 'string'
? part
: {
Expand All @@ -182,7 +184,7 @@ export const generate = async (config: Config): Promise<string[]> => {
[
'// __parts__',
canisterConfig.parts
.map((part, i) => `part_${i}::canpack!();`)
.map((part, i) => `${getPartIdentifier(part, i)}::canpack!();`)
.join('\n'),
],
]);
Expand Down

0 comments on commit 8fee2cd

Please sign in to comment.