core/source/logic/transfer/local.ts

82 lines
1.7 KiB
TypeScript
Raw Permalink Normal View History

2025-09-24 12:39:22 +02:00
/*
This file is part of »mimir«.
Copyright 2025 kcf <fenris@folksprak.org>
»mimir« is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
»mimir« is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with »mimir«. If not, see <http://www.gnu.org/licenses/>.
*/
2025-03-26 07:35:59 +01:00
namespace _mimir.transfer.local
{
2025-09-24 12:39:22 +02:00
/**
*/
export type type_parameters = {
directory : string;
};
2025-03-26 07:35:59 +01:00
/**
*/
export function execute(
2025-09-24 12:39:22 +02:00
parameters : type_parameters,
2025-03-26 07:35:59 +01:00
name : string,
stamp : string,
directory : string
) : Array<string>
{
const result : Array<string> = [];
const target_directory : string = lib_plankton.string.coin(
"{{base}}/{{stamp}}/{{name}}",
{
"base": parameters.directory,
"stamp": stamp,
"name": name,
}
);
result.push(
lib_plankton.string.coin(
"mkdir --parents {{directory}}",
{
"directory": target_directory,
}
)
);
result.push(
lib_plankton.string.coin(
"mv {{directory_from}}/* {{directory_to}}/",
{
"directory_from": directory,
"directory_to": target_directory,
}
)
);
return result;
}
2025-09-24 12:39:22 +02:00
/**
*/
export function logic(
parameters : type_parameters
) : _mimir.transfer.type_logic
{
return {
"execute": (name, stamp, directory) => execute(parameters, name, stamp, directory),
};
}
2025-03-26 07:35:59 +01:00
}