-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-command scripts #7
Comments
Mmm, looks like multi commands are not supported by Deno.run({ cmd: ["mkdir", "newdir", "&&", "cd", "newdir", "&&", "ls -al"]}) And executing them in different subprocesses does not follow the new cwd after the Deno.run({ cmd: ["mkdir", "newdir"]})
Deno.run({ cmd: ["cd", "newdir"]})
Deno.run({ cmd: ["ls -al"]}) I have to investigate how to fix this. |
Ok, I've released 0.9.6 that fixes this. |
I just tried
Not sure if this is related, but as of https://jspm.org/jspm-dev-release |
Oh, I didn't know about Anyway, |
I tried this, it returned v0.9.6, and I ran it, but there was still the same issue. After trying various things, I deleted the cache and tried again. This time it correctly split the commands, so this seems to be the issue I had before with the cache not being cleared correctly. The I'll go back to using a |
could you perhaps try |
I can run this script without problems: site.script("multi",
"mkdir newdir",
"cd newdir",
"touch newfile",
"ls -al",
"cd ..",
"rm -rf newdir"
);
And creating an unique commands with site.script("multi", "mkdir newdir && cd newdir && touch newfile && ls -al && cd .. && rm -rf newdir"); Could I see a command that is not working to you. |
I copied your test exactly, and the full error stack I get is:
I tried with |
I wondered if it might be some peculiarity in my machine's setup, so I pushed to GitLab's CI, using alpine-deno docker container and
so using the latest version, and I get the same problem. Hmm. |
mm, no idea. deno run --unstable -A lume/cli.js --run multi So you can debug the script runner. What I'm doing is detecting whether the last command is With a Maybe the problem is that you need to pass some environment variables? Deno.run has an env option so try to change the code for something like: options.env = Deno.env.toObject(); I'm using macOS without problems, but I'm going to create a testing repository and use the github CI. |
ok, I'll take a look tomorrow |
This doesn't explain this particular issue, but I'm sure it's related somehow, and if it's not going to work in my case anyway ... I prefer to keep the directory tidy and keep the script commands in the config file, so what I could do is change my config file to create a temp file and then execute it. Lume could do this for me, i.e. keep the array of processes for commands that are unrelated, and change the sequential option to create a (executable) file and then run it. And change the docs to explain the difference. What do you think? |
deno also includes all the filesystem cmds like |
Yes, I know. This is why I detect the "cd" command to change the cwd after running the scripts, so the next processed will be runned with the new cwd. You can see it here: https://deno.land/x/lume@v0.9.6/scripts.js#L56 So, basically, what I do is:
Deno.run({ cmd: ["cd", "mydir"] });
Deno.run({ cmd: ["ls", "-al"] }); But using the same options object for two: const options = { cwd: Deno.cwd() };
//Script 1
let cmd = ["cd", "mydir"];
Deno.run({ cmd, ...options });
//Change the cwd
if (cmd[0] === "cd") {
options.cwd = join(options.cwd, cmd[1]);
}
//Script 2
cmd = ["ls", "-al"]
Deno.run({ cmd, ...options }); |
to answer my question about running a js script, I can create an ordinary function in the config file with for example
If I import my script, it's loaded on startup, which I don't want, but I can do https://deno.land/manual/examples/subprocess has an example of using |
Ok, I've the same issue as you in GA: https://github.com/lumeland/test/runs/1470070616#step:4:594 I'll try to fix it and, in addition, add support to assign javascript functions to scripts. So, for example, you could do this: function myFunction () {
// Your code here
}
site.script("my-script", myFunction); So, you can run this function from cli |
yeah, that would make it very versatile. Especially if I could have |
just to confirm, this works as I thought. I changed my script to export a function. This function can then be imported into the config file, and run with a param in the function called by the afterBuild listener. There's then no need for any shell scripts or subprocesses. I additionally have a small front-end for running from the command line which also imports the function and then sets the param to args[0]. If you allow |
Ok, new version released (v0.9.8) with the following changes:
site.script("hello", () =>
site.flags.forEach((flag) => console.log(`hello ${flag}`))
);
|
presumably, a TS error rather than a JS one. I'm on deno 1.5.4. And again, deleting the cache and then reinstalling works. I need to do some research on install, so I understand what's going on here. |
There seems to be some kind of issue with running async functions within a site function. This is the config file I created yesterday, which works fine:
So it simply calls
I've now added:
so I can run |
Ok, I'll check that. |
Ok, I've found the issue. I've also changed the way |
yes, that all seems to work now, thanks. I'd suggest adding some docs/examples on how to use flags. |
I've been trying out the script runner. I have what's probably a common setup, where I convert md files to html, and then want to run other scripts to create other parts of the site. So the script looks something like:
I put this in a separate
.sh
file, which works fine. But I would prefer to include this in the Lume config file, and I can't find a way to do this. If I put the cmds in one line separated by;
, then it makes dirs callednewdir;
,cd
, etc. The same with separating the cmds with&&
. I also tried using the sequential option, but it looks like it tries tocd
beforemkdir
has completed, so that doesn't work either.Any ideas?
The text was updated successfully, but these errors were encountered: