Skip to content

action fails when a lib directory exists #8

@splitbrain

Description

@splitbrain

The action tries to move the plugin from . to lib/plugin/<name>:

moveContents('.', config.dir);

This is executed here:

function moveContents(sourceDir, destinationDir) {
// read contents first
const items = fs.readdirSync(sourceDir);
// then create destination dir if it doesn't exist
if (!fs.existsSync(destinationDir)) {
fs.mkdirSync(destinationDir, {recursive: true});
}
for (const item of items) {
const sourcePath = path.join(sourceDir, item);
const destinationPath = path.join(destinationDir, item);
const stats = fs.statSync(sourcePath);
if (stats.isFile()) {
fs.renameSync(sourcePath, destinationPath);
} else if (stats.isDirectory()) {
moveContents(sourcePath, destinationPath);
fs.rmdirSync(sourcePath);
}
}
}

Line 15 will read the list of all files and directories. This will include a lib directory if it exists in the plugin.

It then proceeds to copy all files to lib, recursing into directories. It will try to copy lib to lib which is interpreted as lib -> lib/lib. The next recursion will find this lib/lib creating lib/lib/lib and so on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions