Skip to content

Commit d47b16c

Browse files
committed
🦦 co-publish to @nodef org
1 parent 68cddb5 commit d47b16c

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ A [string] is a sequence of characters.
22

33
▌
44
📦 [JSR](https://jsr.io/@nodef/extra-string),
5-
📦 [NPM](https://www.npmjs.com/package/extra-string),
5+
📦 [NPM](https://www.npmjs.com/package/@nodef/extra-string),
66
📰 [Docs](https://jsr.io/@nodef/extra-string/doc).
77

88
In JavaScript, strings are not [mutable]. Any transfomation of a *string*, such as `slice` or `concat` generates a *new string*. The *JavaScript runtime* however may optimize this behavior by *mutating strings behind the scenes*, when it can be guarenteed that the previous string is *not accessible* to the programmer. The *runtime* may also *avoid copying slices* of a string, or even *concatenation of slices of* *strings*, by implementing it as a *series of lookups into existing strings*. Food for thought.

‎build.ts‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ async function run(command: string, args: string[], cwd?: string) {
1515

1616

1717
// Publish core package to npm.
18-
async function publishCoreToNpm() {
19-
const name = JSON.parse(await Deno.readTextFile('deno.json')).name.replace(/^@nodef\//, '');
18+
async function publishCoreToNpm(name: string) {
19+
const file = name.replace(/\//g, '__');
2020
console.log(`Publishing the ${name} package to npm...`);
21-
await run('deno', ['pack', '--output', `${name}.tgz`, '--allow-dirty']);
21+
await run('deno', ['pack', '--output', `${file}.tgz`, '--allow-dirty']);
2222
Deno.mkdirSync('.temp-pack', {recursive: true});
23-
await run('tar', ['-xzf', `${name}.tgz`, '-C', '.temp-pack']);
24-
Deno.removeSync(`${name}.tgz`);
23+
await run('tar', ['-xzf', `${file}.tgz`, '-C', '.temp-pack']);
24+
Deno.removeSync(`${file}.tgz`);
2525
const meta = JSON.parse(await Deno.readTextFile('.temp-pack/package/package.json'));
2626
meta.name = name;
27+
// meta.bin = {"sleep": "bin.js"};
2728
await Deno.writeTextFile('.temp-pack/package/package.json', JSON.stringify(meta, null, 2));
2829
await run('npm', ['publish', '--access', 'public'], '.temp-pack/package');
2930
await Deno.remove('.temp-pack', {recursive: true});
@@ -32,12 +33,15 @@ async function publishCoreToNpm() {
3233

3334
// Main function, of course.
3435
async function main() {
36+
const meta = JSON.parse(await Deno.readTextFile('deno.json'));
37+
const name = meta.name.replace(/^@nodef\//, '');
3538
const args = parseArgs(Deno.args, {
3639
boolean: ['publish-core'],
3740
default: {'publish-core': false}
3841
});
3942
if (args['publish-core']) {
40-
await publishCoreToNpm();
43+
await publishCoreToNpm(name);
44+
await publishCoreToNpm(`@nodef/${name}`);
4145
}
4246
}
4347
main();

‎deno.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nodef/extra-string",
3-
"version": "2.4.3",
3+
"version": "2.4.4",
44
"license": "MIT",
55
"exports": "./index.ts",
66
"exclude": [

0 commit comments

Comments
 (0)