Method, device, equipment, medium and product for running script language file

By identifying and launching the target scripting language runtime environment version for multiple terminal sessions, the problem of not being able to use different scripting language runtime environment versions simultaneously in the prior art is solved, enabling the simultaneous use of different scripting language runtime environment versions in multiple terminal sessions, thus improving the system's flexibility and stability.

CN115408120BActive Publication Date: 2026-08-04DOUYIN VISION CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
DOUYIN VISION CO LTD
Filing Date
2022-06-29
Publication Date
2026-08-04

AI Technical Summary

Technical Problem

In existing technologies, only one scripting language runtime environment version can be used in multiple terminal sessions at the same time, which makes it impossible to use different scripting language runtime environment versions in different terminal sessions simultaneously, potentially leading to build task anomalies.

Method used

By responding to the execution commands of the terminal session, the target scripting language runtime environment version corresponding to each terminal session is determined, and the target scripting language runtime environment version is launched as a child process through a pre-generated launcher, so as to enable the simultaneous use of different scripting language runtime environment versions in multiple terminal sessions.

Benefits of technology

This allows for the simultaneous use of different scripting language runtime environment versions in multiple terminal sessions, avoiding build task anomalies and improving the system's flexibility and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115408120B_ABST
    Figure CN115408120B_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure disclose a script language file running method, device, equipment, medium and product. The method comprises: in response to an operation of executing a command in at least two terminal sessions at the same time, determining a target script language running environment version corresponding to each terminal session under a current operating system; starting the target script language running environment version in the form of a sub-process through a pre-generated launcher, so as to run a corresponding script language file through the target script language running environment version. Embodiments of the present disclosure solve the problem that different script language running environment versions cannot be used simultaneously in multiple terminal sessions, so that different script language running environment versions can be used simultaneously in multiple terminal sessions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a method, apparatus, device, medium and product for running script language files. Background Technology

[0002] Currently, in Windows, the scripting runtime environment can only be switched by creating symbolic links between different versions of the scripting runtime environment in a folder. This means that only one version of the scripting runtime environment can be used at a time, and different versions of the scripting runtime environment cannot be used in different terminal sessions at the same time.

[0003] In the current operating system, if tenant A is using version A for building or other tasks, and another tenant B enters and wants to use version B, the current solution might cause tenant A's build task to malfunction. Therefore, how to enable the simultaneous use of different scripting language runtime environment versions across multiple terminal sessions is a problem that urgently needs to be solved.

[0004] Public content

[0005] In view of this, the present disclosure provides a method, apparatus, device, medium and product for running script language files, which enables the simultaneous use of different script language runtime environment versions in multiple terminal sessions.

[0006] According to one aspect of this disclosure, embodiments of this disclosure provide a method for running a scripting language file, the method comprising:

[0007] In response to the operation of executing commands on at least two terminal sessions at the same time, determine the target scripting language runtime environment version corresponding to each terminal session under the current operating system;

[0008] The target scripting language runtime environment version is launched as a child process using a pre-generated launcher, so that the corresponding scripting language file can be run using the target scripting language runtime environment version.

[0009] According to another aspect of this disclosure, embodiments of this disclosure also provide a scripting language file execution apparatus, the apparatus comprising:

[0010] The determination module is used to determine the target scripting language runtime environment version corresponding to each terminal session under the current operating system in response to the operation of the execution command of at least two terminal sessions at the same time;

[0011] The startup module is used to launch the target scripting language runtime environment version as a subprocess via a pre-generated launcher, so as to run the corresponding scripting language file through the target scripting language runtime environment version.

[0012] According to another aspect of this disclosure, embodiments of this disclosure also provide an electronic device, the electronic device comprising:

[0013] At least one processor; and

[0014] A memory communicatively connected to the at least one processor; wherein,

[0015] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to execute the script language file running method described in any embodiment of this disclosure.

[0016] According to another aspect of this disclosure, embodiments of this disclosure also provide a computer-readable storage medium storing computer instructions for causing a processor to execute a method for running a script language file as described in any embodiment of this disclosure.

[0017] According to another aspect of this disclosure, embodiments of this disclosure also provide a computer program product, the computer program product including a computer program, which, when executed by a processor, implements the method for running script language files as described in any embodiment of this disclosure.

[0018] The technical solution of this disclosure solves the problem that different scripting language runtime environment versions cannot be used simultaneously in multiple terminal sessions by determining the target scripting language runtime environment version corresponding to each terminal session under the current operating system, and starting the target scripting language runtime environment version as a child process through a pre-generated launcher, so as to run the corresponding scripting language file through the target scripting language runtime environment version. This enables the simultaneous use of different scripting language runtime environment versions in multiple terminal sessions.

[0019] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0020] To more clearly illustrate the technical solutions in the embodiments of this disclosure, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 A flowchart illustrating a method for running a scripting language file, provided in an embodiment of this disclosure;

[0022] Figure 2 A flowchart illustrating another method for running a scripting language file provided in this embodiment of the disclosure;

[0023] Figure 3 A flowchart illustrating another method for running a scripting language file provided in this embodiment of the disclosure;

[0024] Figure 4 A flowchart illustrating another method for running a scripting language file provided in this embodiment of the disclosure;

[0025] Figure 5 This is a structural block diagram of a scripting language file execution device provided in an embodiment of the present disclosure;

[0026] Figure 6 A schematic diagram of the structure of an electronic device that can be used to implement embodiments of the present disclosure is shown. Detailed Implementation

[0027] To enable those skilled in the art to better understand the present disclosure, the technical solutions of the present disclosure will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of the present disclosure, and not all embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present disclosure.

[0028] It should be noted that the terms "target," etc., in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0029] In one embodiment, Figure 1 This is a flowchart illustrating a method for running a scripting language file, provided in an embodiment of this disclosure. This embodiment is applicable to situations where different versions of scripting language files are used in multiple terminal sessions. The method can be executed by a scripting language runtime environment (SMI) scripting file execution device. This scripting language file execution device can be implemented in hardware and / or software, and can be configured in an electronic device. For example... Figure 1 As shown, the method includes:

[0030] S110. In response to the operation of executing commands on at least two terminal sessions at the same time, determine the target scripting language runtime environment version corresponding to each terminal session under the current operating system.

[0031] In this context, "terminal session" refers to the program runtime environment provided by command prompts (such as Cmd, PowerShell, and Bash) under Windows. The current operating system can be understood as the environment used to compile and build software during the software release process. The target scripting language runtime environment version can be understood as the version of the scripting language runtime environment set by the user under the current operating system. For example, the scripting language runtime environment could be Node.js, and correspondingly, the target scripting language runtime environment version could refer to the target Node.js version.

[0032] In this embodiment, the current operating system can be a continuous integration runtime environment or an office environment; this embodiment does not impose any limitations. The execution command can be a command executed by the scripting language runtime environment. For example, the execution command can include basic commands such as node, npm, and npx, meaning that the scripting language runtime environment comes with these three basic commands after installation. Of course, the execution command can also include other third-party commands installed by the user according to their needs (such as tsc, gulp, etc.), and the naming of the third-party commands is different from the naming of the basic commands mentioned above.

[0033] In this embodiment, in response to at least two terminal sessions executing commands on the scripting language runtime environment simultaneously, the target scripting language runtime environment version corresponding to each terminal session under the current operating system can be determined. It should be noted that each different terminal session can correspond to different target scripting language runtime environment versions simultaneously. The target scripting language runtime environment version may include the scripting language runtime environment version number or the processor architecture; this embodiment does not impose any limitations.

[0034] Specifically, at least two terminal sessions can be launched simultaneously to execute commands related to the scripting language runtime environment. This can be done by setting appropriate environment variables under the current operating system to specify the target scripting language runtime environment version required for each terminal session; alternatively, stored configuration files can be used to determine the target scripting language runtime environment version for different terminal sessions. These stored configuration files can be understood as stored data information and can be modified using command-line tools. Commands related to the scripting language runtime environment can include one of the following: an interactive programming environment opened directly by the `node` command without parameters; a command to run the script by passing the scripting language file path as an argument to the `node` command; the `npm` command for installing third-party programs; the `npx` command for running third-party programs; or custom commands defined by third-party programs (e.g., `tsc`, `gulp`).

[0035] In one embodiment, the target scripting language runtime environment version includes at least the following parameters: scripting language runtime environment version number and processor architecture.

[0036] The scripting language runtime environment (RUME) version number can be understood as the version number of the target RUME corresponding to each terminal session. Of course, the RUME version number can be set by the user, and different RUME versions will have slight differences. For example, version number 18 refers to the RUME version number, while other versions may not be supported.

[0037] In this embodiment, the target scripting language runtime environment version corresponding to each terminal session under the current operating system includes at least: the scripting language runtime environment version number and the processor architecture. Specifically, Node.js is a specific version compiled for a processor with a certain architecture, meaning this version can be used by processors of that specific architecture. For example, x86 can only be used on AMD and Intel CPUs.

[0038] S120. The target scripting language runtime environment version is launched as a child process through the pre-generated launcher, so as to run the corresponding scripting language file through the target scripting language runtime environment version.

[0039] In this context, a child process can be understood as a process created by another process, which can be referred to as the parent process. It's important to understand that a process may have multiple child processes, but it can have at most one parent process. It's worth noting that a child process inherits most of the attributes of its corresponding parent process, such as environment variables.

[0040] In this embodiment, a scripting language file can be understood as a file with the .js extension, such as xx.js. A scripting language file refers to a script program written in JavaScript, typically used for dynamic operations on web pages. However, in this scenario, JavaScript is usually used as a functional script. Therefore, the scripting language file can be a JS script file.

[0041] In this embodiment, a pre-generated launcher can be used to launch an executable file of a certain command. For example, the node command will have an executable file named node or node.exe. Multiple launchers can be created, and the launcher used to execute which command can be distinguished by reading the corresponding file name.

[0042] In this embodiment, if a user uses a command in the terminal, the system will find the corresponding executable file for that command. For example, the `node` command on Windows will use an executable file named `node.exe`. In the application scenario, since the `node.exe` executable file has already been generated and is considered by the system to be usable as a command, the launcher will run when the user executes the `node` command. The launcher can obtain its own filename; for example, `node.exe` indicates that the user wants to execute the `node` command. The launcher will then search for the scripting language runtime environment version set by the user through environment variables, locate the corresponding version of the scripting language runtime environment that the user has installed, and execute the program corresponding to the `node` command in that scripting language runtime environment version—the actual scripting language runtime environment script execution program `node.exe` (which has the same name as the launcher but is not the same thing; one is the launcher, and the other is the program being launched). For commands other than `node.exe`, such as `npm / npx` or commands manually installed by the user, a launcher with the same name will also be generated. However, what they ultimately launch are scripting language files, not executable programs. For example, these two commands will eventually generate corresponding launchers npm.exe and npx.exe, but when these launchers run, they will use the scripting language runtime environment (not the launcher's named node.exe) to run the predefined scripting language files corresponding to the npm, npx, etc. commands. Therefore, it is necessary to clearly list the launcher's behavior for different commands: ① Command: node, the most important user-run script command, generates a launcher node.exe, which directly launches the actual node.exe of the corresponding version of the scripting language runtime environment; ② Command: npm, a built-in function command of node, generates a launcher npm.exe, which launches its corresponding npm.js script through the corresponding version of the scripting language runtime environment; ③ Command: tsc, a third-party command manually installed by the user, generates a launcher tsc.exe, which launches its corresponding tsc.js script through the corresponding version of the scripting language runtime environment.

[0043] The technical solution of this embodiment solves the problem that different scripting language runtime environment versions cannot be used simultaneously in multiple terminal sessions by determining the target scripting language runtime environment version corresponding to each terminal session under the current operating system, and starting the target scripting language runtime environment version as a child process through a pre-generated launcher, so as to run the corresponding scripting language file through the target scripting language runtime environment version. This enables the simultaneous use of different scripting language runtime environment versions in multiple terminal sessions.

[0044] In one embodiment, Figure 2This is a flowchart illustrating another method for running a scripting language file, provided in this embodiment of the present disclosure. This embodiment further refines the methods described above, such as... Figure 2 As shown, the method for running the script language file in this embodiment may specifically include the following steps:

[0045] S210. In response to the operation of executing commands on at least two terminal sessions at the same time, determine the target scripting language runtime environment version corresponding to each terminal session under the current operating system.

[0046] S220. Obtain the compressed package of the scripting language runtime environment version corresponding to the target scripting language runtime environment version.

[0047] In this embodiment, the user can select the target scripting language runtime environment version they want to install. The program will automatically download the corresponding scripting language runtime environment version release package from the official website of the target scripting language runtime environment version and decompress the corresponding scripting language runtime environment version release package.

[0048] It should be noted that the installation function for the target scripting language runtime environment version can include downloading the compressed package of the target scripting language runtime environment version, decompressing the compressed package, determining the folder name of the corresponding scripting language files after decompression, and writing the configuration file of the target scripting language runtime environment version.

[0049] S230. Extract the compressed package of the scripting language runtime environment version to the pre-created target folder.

[0050] The target folder is named using the scripting language runtime environment version number that corresponds to the target scripting language runtime environment version. For example, the target folder can be named using the scripting language runtime environment version number minus the processor architecture.

[0051] The compressed package for the scripting language runtime environment (RUO) release version can be understood as a compressed package of the ROOM version that has passed testing and been released to the market. This ROOM release version can be downloaded from the target URL. For example, the target URL can be the official website of the ROOM.

[0052] In this embodiment, after obtaining the compressed package corresponding to the target scripting language runtime environment version, the compressed package can be decompressed to a pre-created target folder. For example, when a user selects the compressed package for the scripting language runtime environment version, downloads it, and then decompresses it to the folder corresponding to the scripting language runtime environment version.

[0053] S240. Store the access path of the target folder and the corresponding scripting language runtime environment version number in a pre-created configuration file.

[0054] The pre-created configuration file can be understood as the relevant data and attribute information of the script language file. For example, it can be the relevant information of the script language runtime environment version number, or the relevant attribute information of the processor architecture. This embodiment does not impose any restrictions here.

[0055] In this embodiment, the access path of the target folder, the corresponding scripting language runtime environment version number, processor architecture, and whether it supports Long Term Support (LTS) can be stored in a pre-created configuration file. The configuration file can be modified using commands; for example, the default version number and processor architecture of the target scripting language runtime environment can be set.

[0056] In one embodiment, the attribute information includes: the scripting language runtime environment version number, the processor architecture, and whether it is a Long Term Support (LTS) system.

[0057] In this embodiment, the attribute information of the script language file corresponding to the target script language runtime environment version after decompression may include script language runtime environment version number information, processor architecture information, and whether it is supported by Long Term Support (LTS).

[0058] S250. The target scripting language runtime environment version is launched as a child process through a pre-generated launcher, so as to run the corresponding scripting language file through the target scripting language runtime environment version.

[0059] The above technical solution of this disclosure embodiment, based on the above embodiment, obtains the compressed package of the scripting language runtime environment version corresponding to the target scripting language runtime environment version in real time, determines the name of the folder where the decompressed product of the compressed package of the scripting language runtime environment version is saved; and can automatically store the scripting language runtime environment version information carrying the folder name to a pre-created configuration file, and update the configuration file so that different target scripting language runtime environment versions can be switched in real time when multiple terminals are in a session.

[0060] In one embodiment, Figure 3 This is a flowchart illustrating another method for running a scripting language file, provided as an embodiment of the present disclosure. This embodiment further refines the methods described above, such as... Figure 3 As shown, the method for running the script language file in this embodiment may specifically include the following steps:

[0061] S310. In response to the operation of executing commands on at least two terminal sessions at the same time, determine the target scripting language runtime environment version corresponding to each terminal session under the current operating system.

[0062] S320. Store at least two pre-created launchers in a preset folder.

[0063] The default folder, also known as the bin folder, refers to the program that users store that can be executed as a command in the terminal. It is usually named bin and added to the PATH environment variable so that executable files in the folder can be run directly in the terminal. The bin folder contains many executable files, such as node.exe and npm.exe, allowing the use of the node and npm commands directly in the terminal.

[0064] In this embodiment, the launcher refers to the main launcher of the scripting language, which can be the main program of the scripting language runtime environment, such as node.exe, or a package management tool, such as npm.exe.

[0065] S330: Read at least one command-line script from the installation directory of each pre-scanned scripting language runtime environment.

[0066] In this embodiment, at least one command-line script in the installation directory of each scripting language runtime environment version is read. For example, it can be foo or foo.cmd. Files named in this form can usually be understood as global commands installed by the user through npm in the target scripting language runtime environment version. At the same time, npm itself also exists in this form as npm and npm.cmd.

[0067] It should be noted that the system needs to scan the command-line scripts in the installation directory of each scripting language runtime environment (for example, there are three command-line scripts named foo.cmd, bar.cmd, and baz cmd) to obtain one or more commands that need to be added. For example, foo, bar, and baz will be registered for each command. The registration operation can include three steps: First, read the contents of the command-line script file (e.g., foo.cmd) and find the actual JS script file path (e.g., node_modules, .bin, oo.js) corresponding to the command (foo); Second, store the correspondence between the command (foo) and the scanned JS script file path (node_modules, bin, foo.js) in a configuration file; Third, create the launcher (foo.exe) corresponding to the command (foo).

[0068] It should be noted that a global command scan is required after each user runs an npm command. This is because running an npm command can generate new commands, which necessitates the scan.

[0069] In this embodiment, the execution order of S320 and S330 is not restricted. S320 can be executed first and then S330; S330 can be executed first and then S320; or S320 and S330 can be executed simultaneously.

[0070] S340. Scan the corresponding script language file path in each command-line script.

[0071] In this embodiment, within each command-line script in the installation directory of each scripting language runtime environment, the path of the scripting language file corresponding to each command-line script is scanned and parsed accordingly. The path of the scripting language file is then determined through appropriate expressions. For example, the corresponding scripting language file path may be scanned within the `node`, `npx`, and `npm` lines of script.

[0072] S350. Store the mapping between target commands and script language file paths in the corresponding configuration file.

[0073] The target command is the command corresponding to the command-line script.

[0074] In this embodiment, the mapping between target commands and script language file paths can be stored in a corresponding configuration file. It should be noted that the target command is the command corresponding to the command-line script, and target commands can be divided into different command types, such as node commands or non-node commands. For example, if the target command is node, it can be called a node command type; if the target command is non-node, it can be called a non-node command type.

[0075] S360, Create the launcher corresponding to the target command.

[0076] In this embodiment, the launcher is distributed along with the tool. A launcher can generally be understood as an executable file. In this embodiment, a launcher corresponding to the target command needs to be created. For example, the executable file is launcher.exe. If a launcher is to be created for the target command foo, launcher.exe will be copied and renamed foo.exe.

[0077] In this embodiment, the target command and the launcher name correspond to each other; they can be considered to be the same. For example, when the target command is "node", you need to type "node" in the terminal, and the corresponding launcher will be a program named "node" or "node.exe". The launcher name corresponds to the target command, but the target command may not contain "exe".

[0078] S370. The target scripting language runtime environment version is launched as a child process through a pre-generated launcher, so as to run the corresponding scripting language file through the target scripting language runtime environment version.

[0079] The above technical solution of this disclosure embodiment reads at least one command-line script in the installation directory of each pre-scanned script language runtime environment, scans the corresponding script language file path in each command-line script, stores the correspondence between the target command name and the script language file path in the corresponding configuration file, and creates a launcher corresponding to the target command, thereby realizing automatic scanning and generation of a launcher for executing the command.

[0080] In one embodiment, Figure 4 This is a flowchart illustrating another method for running a scripting language file according to an embodiment of this disclosure. Based on the aforementioned embodiments, this embodiment further refines the determination of the target scripting language runtime environment version corresponding to each terminal session under the current operating system, and the launching of the target scripting language runtime environment version as a subprocess via a pre-generated launcher, so as to run the corresponding scripting language file using the target scripting language runtime environment version. For example... Figure 4 As shown, the method includes:

[0081] S410. In response to the operation of executing commands on at least two terminal sessions at the same time, determine the target scripting language runtime environment version corresponding to each terminal session under the current operating system.

[0082] In this embodiment, the S410 implementation scheme can include two types. One type is: in response to the operation of starting a scripting language runtime environment and corresponding commands (e.g., three different commands: node, npm, and npx) for at least two terminal sessions at the same time, obtaining the environment variables of the parent process or terminal session under the current operating system, and determining the target scripting language runtime environment version corresponding to the terminal session based on the environment variables. The other type is: in response to the operation of starting at least two terminal sessions at the same time, determining the target scripting language runtime environment version corresponding to the terminal session based on a pre-stored configuration file.

[0083] In this context, a parent process can be understood as a process that has created one or more child processes. Environment variables can be understood as parameters used in the operating system to specify the operating system's runtime environment, such as the location of temporary folders and system folders. Environment variables contain information used by one or more applications. For example, the PATH environment variable in Windows requires the system to run a program without specifying its full path. In addition to searching for the program in the current directory, the system should also search the paths specified in the PATH. Users can optimize process execution by setting the PATH environment variable.

[0084] In this embodiment, in response to the operation of executing commands on at least two terminal sessions simultaneously, the relevant environment variables of the parent process or terminal session under the current operating system environment can be obtained. Users can specify the required target scripting language runtime environment version information under the current operating system by setting the corresponding environment variables. It should be noted that, in response to the operation of executing commands on at least two terminal sessions simultaneously, the target scripting language runtime environment version corresponding to the terminal session can be determined by using the obtained environment variables of the parent process or terminal session under the current operating system, or by using pre-stored relevant configuration files.

[0085] S420. If the target command is a Type 1 command, the executable file in the installation directory of the target scripting language runtime environment version is launched directly as a child process through the launcher.

[0086] The first type of command can be understood as a command that directly launches an executable file in the installation directory of the target scripting language runtime environment version as a child process via the launcher. For example, the first type of command can be the `node` command, and the executable file in the installation directory of the scripting language runtime environment can be the `node.exe` file.

[0087] In this embodiment, when the command type corresponding to the filename of the target scripting language runtime environment version is a first-type command, the executable file in the installation directory of the scripting language runtime environment version can be launched directly as a child process via the launcher. Specifically, it can be generated using a command-line tool. This command-line tool can include installation and switching functions for the target scripting language runtime environment version, and can provide a command to scan all npm global commands under all installed target scripting language runtime environment versions.

[0088] S430. If the target command is a second type command, the launcher obtains and reads the target script language runtime environment version and the location of the script language file corresponding to the target command, and executes the script language file in the form of a child process through the script language runtime environment.

[0089] The second type of command can be understood as a command that obtains and reads the location of the script language file corresponding to the target script language runtime environment version through the launcher, and executes the script language file as a child process through the script language runtime environment. For example, the second type of command can be a non-node command.

[0090] In this embodiment, when the command type corresponding to the file name of the target scripting language runtime environment version is a first-type command, the launcher can obtain and read the configuration to find the location of the scripting language file corresponding to the target scripting language runtime environment version, and execute the scripting language file as a child process through the scripting language runtime environment. Specifically, the command-line tool can read the configuration file to obtain the target scripting language runtime environment version to execute the script file, and then execute the corresponding command.

[0091] It should be noted that when the file name corresponding to the target scripting language runtime environment version has a different command type, there are also corresponding operations. For example, for the npm -g command, since the npm -g command adds or removes global npm commands, it is necessary to call the command scanning function in the command line tool when the npm -g command finishes running.

[0092] The above-disclosed technical solution obtains the environment variables of the parent process or terminal session under the current operating system and determines the target scripting language runtime environment version corresponding to the terminal session based on the environment variables; or, it determines the target scripting language runtime environment version corresponding to the terminal session based on a pre-stored configuration file, and when the target command is a first type of command, it directly launches the executable file in the scripting language runtime environment installation directory where the target scripting language runtime environment version is located as a child process through the launcher; when the target command is a second type of command, it obtains and reads the location of the scripting language file corresponding to the target scripting language runtime environment version and the target command through the launcher, and executes the JS script file through the scripting language runtime environment as a child process, thereby further solving the problem that different scripting language runtime environment versions cannot be used simultaneously in multiple terminal sessions, and realizing that different scripting language runtime environment versions can be used simultaneously in multiple terminal sessions.

[0093] In one embodiment, this disclosure provides a workflow for launching a launcher, wherein if the scripting language runtime environment version is Node.js, then the target Node.js version is used as the target scripting language runtime environment version; the current operating system can be a continuous integration environment. `node` commands are represented as first-type commands; non-`node` commands are represented as second-type commands; and the `node.exe` file is represented as an executable file, as detailed below:

[0094] In this embodiment, a launcher is an executable file used to launch a specific command. For example, the `node` command might have an executable file named `node` or `node.exe`. Multiple launchers can be created, but they are essentially the same program. However, each launcher distinguishes itself by reading its own filename to determine which command it is used to execute.

[0095] The specific workflow when the launcher is started is as follows:

[0096] a1. Obtain the Node.js version the user wants to use. The Node.js version can be obtained in two ways: one is through environment variables in the parent process or terminal session, meaning the user can specify the Node.js version to be used in the current continuous integration environment by setting environment variables. The other is through a pre-stored configuration file, which can be modified using command-line tools to set the globally default Node.js version.

[0097] a2. Read the filename of the Node.js version. For example, on Windows it is node.exe, so the command is node. On Unix-like operating systems, the command and filename are the same.

[0098] a3. For the `node` command, you can directly launch a child process by executing the `node.exe` file located in the directory of the desired Node.js version. If the desired Node.js version does not exist, an error will be displayed. The directory for the desired Node.js version can be read from a configuration file and generated using a command-line tool.

[0099] a4. For non-Node commands, the command-line tool will analyze the location of the .js script file corresponding to the Node.js version. Therefore, you only need to read the location of the corresponding .js script file from the configuration file and execute the script using Node.js by starting a child process to execute the non-Node command.

[0100] In this embodiment, the launcher performs some additional operations when executing commands: for the npm -g command, since this command adds or removes new npm global commands, it is necessary to call the command scanning function in the command line tool when this command finishes running.

[0101] In one embodiment, this disclosure provides a workflow for a command-line Node.js version installation function, and the specific steps are as follows:

[0102] In this embodiment, the command-line tool includes functions for installing and switching Node.js versions, and provides a command to scan all npm global commands under all installed Node.js versions.

[0103] The Node.js version installation function mainly includes: downloading, decompressing, and writing configuration files for the Node.js version.

[0104] In this embodiment, the main workflow of the command-line Node.js version installation function is as follows:

[0105] b1. Based on the Node.js version the user wants to install, download the corresponding Node.js version compressed package from the official Node.js website.

[0106] b2. Unzip the downloaded compressed file and name the folder in the format of version-processor architecture.

[0107] b3. Store the version number, architecture, and whether it is LTS information of the downloaded Node.js compressed package in the configuration file.

[0108] In this embodiment, the Node.js version switching function is mainly used to switch the default Node.js version, and the running command is used to modify the configuration file to set the default Node.js version and processor architecture to be used.

[0109] In one embodiment, this disclosure provides a workflow for scanning global commands, where the bin folder represents a preset folder, and the specific steps are as follows:

[0110] In this embodiment, the purpose of scanning global commands is twofold: first, to create basic commands such as node, npm, and npx; and second, to scan the global commands of npm installed on all Node.js versions.

[0111] The main workflow of the global scan command is as follows:

[0112] c1. Create launchers named node, npm, and npx, and place them in the bin folder. The bin folder refers to the folder that stores global commands. It can be the system's default bin folder or a folder created by the version manager itself. If you create a folder yourself, you need to add it to the operating system's PATH environment variable so that you can run the executable files in the folder directly in the terminal.

[0113] c2. Scan the command-line scripts in each Node.js installation directory. Files named in this format, such as foo, foo.cmd, and foo.ps1, are usually global commands installed by npm in this version of Node.js. Parse their contents and use regular expressions to analyze and identify the .js script files they point to.

[0114] c3. Store the "command name" and ".js script file corresponding to the Node.js version" of the scanned launcher into a pre-stored configuration file.

[0115] In one embodiment, Figure 5 This is a structural block diagram of a scripting language file execution device provided in an embodiment of this disclosure. This device is suitable for situations where different versions of scripting language files are used in multiple terminal sessions. The device can be implemented in hardware or software. It can be configured in an electronic device to implement a scripting language file execution device according to an embodiment of this disclosure. It should be noted that the scripting language file execution device can be a launcher, which includes a determining module and a launching module. Specifically, the determining module in the launcher determines the target scripting language runtime environment version corresponding to each terminal session under the current operating system; the launching module in the launcher runs the corresponding scripting language file according to the target scripting language runtime environment version.

[0116] like Figure 5 As shown, the device includes a determination module 510 and a startup module 520.

[0117] The determining module is used to determine the target scripting language runtime environment version corresponding to each terminal session under the current operating system in response to the operation of executing commands on at least two terminal sessions at the same time.

[0118] The startup module is used to launch the target scripting language runtime environment version as a subprocess via a pre-generated launcher, so as to run the corresponding scripting language file through the target scripting language runtime environment version.

[0119] The technical solution of this disclosure includes a determining module that, in response to the operation of executing commands on at least two terminal sessions at the same time, determines the target scripting language runtime environment version corresponding to each terminal session under the current operating system; and a starting module that starts the target scripting language runtime environment version as a child process through a pre-generated starter, so as to run the corresponding scripting language file through the target scripting language runtime environment version. This solves the problem that different scripting language runtime environment versions cannot be used simultaneously in multiple terminal sessions, and enables the simultaneous use of different scripting language runtime environment versions in multiple terminal sessions.

[0120] In one embodiment, the means for running a scripting language file includes:

[0121] The compressed package acquisition module is used to acquire the compressed package of the scripting language runtime environment version distribution corresponding to the target scripting language runtime environment version before the target scripting language runtime environment version is launched as a subprocess through a pre-generated launcher to run the corresponding scripting language file through the target scripting language runtime environment version.

[0122] The naming module is used to decompress the compressed package of the scripting language runtime environment version release to a pre-created target folder; wherein, the target folder is named according to the scripting language runtime environment version number corresponding to the target scripting language runtime environment version;

[0123] The first storage module is used to store the access path of the target folder and the corresponding scripting language runtime environment version number into a pre-created configuration file.

[0124] In one embodiment, the device for running script language files further includes:

[0125] The second storage module is used to store at least two pre-created launchers in a preset folder before the target scripting language runtime environment version is launched as a subprocess through the pre-generated launcher to run the corresponding scripting language file through the target scripting language runtime environment version.

[0126] In one embodiment, the device for running script language files further includes:

[0127] The script reading module reads at least one command-line script from the installation directory of each pre-scanned scripting language runtime environment.

[0128] The file scanning module is used to scan the corresponding script language file path in each command line footer;

[0129] The third storage module is used to store the correspondence between the target command and the script language file path in the corresponding configuration file, wherein the target command is the command corresponding to the command line script.

[0130] In one embodiment, the determining module 510 includes:

[0131] The variable acquisition unit is used to acquire environment variables of the parent process or terminal session under the current operating system.

[0132] The first version determination unit is used to determine the target scripting language runtime environment version corresponding to the terminal session based on the environment variables.

[0133] In one embodiment, the determining module 510 further includes:

[0134] The second version determination unit is used to determine the target scripting language runtime environment version corresponding to the terminal session based on the pre-stored configuration file.

[0135] In one embodiment, the startup module 520 further includes:

[0136] The first startup unit is used to directly launch the executable file in the scripting language runtime environment installation directory where the target scripting language runtime environment version is located in the form of a child process through the launcher if the target command is a first type command.

[0137] The second startup unit is used to, if the target command is a second type of command, obtain and read the target script language runtime environment version and the location of the script language file corresponding to the target command through the launcher, and execute the script language file in the form of a subprocess through the script language runtime environment.

[0138] In one embodiment, the attribute information includes: the scripting language runtime environment version number, the processor architecture, and whether it is a Long Term Support (LTS) system.

[0139] In one embodiment, the target scripting language runtime environment version includes at least the following parameters: scripting language runtime environment version number and processor architecture.

[0140] The script language file execution device provided in this disclosure can execute the script language file execution method provided in any embodiment of this disclosure, and has the corresponding functional modules and beneficial effects of the execution method.

[0141] In one embodiment, Figure 6 A schematic diagram of an electronic device that can be used to implement embodiments of the present disclosure is shown. The electronic device 10 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0142] like Figure 6 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0143] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0144] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as the method of running script language files.

[0145] In some embodiments, the method for running a scripting language file may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the method for running a scripting language file described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to execute the method for running a scripting language file by any other suitable means (e.g., by means of firmware).

[0146] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0147] Computer programs used to implement the methods of this disclosure may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0148] In the context of this disclosure, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0149] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0150] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.

[0151] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.

[0152] In one embodiment, this disclosure also provides a computer program product, the computer program product including a computer program, which, when executed by a processor, implements the method for running a script language file according to any of the above embodiments.

[0153] According to one or more embodiments of this disclosure, [Example 1] provides a method for running a scripting language file, including:

[0154] In response to the operation of executing commands on at least two terminal sessions at the same time, determine the target scripting language runtime environment version corresponding to each terminal session under the current operating system;

[0155] The target scripting language runtime environment version is launched as a child process using a pre-generated launcher, so that the corresponding scripting language file can be run using the target scripting language runtime environment version.

[0156] According to one or more embodiments of this disclosure, [Example 2] provides the method of Example 1, which, before launching the target scripting language runtime environment version as a subprocess via a pre-generated launcher to run the corresponding scripting language file via the target scripting language runtime environment version, further includes:

[0157] Obtain the compressed package of the scripting language runtime environment version release corresponding to the target scripting language runtime environment version;

[0158] Extract the compressed package of the scripting language runtime environment version to a pre-created target folder; wherein, the target folder is named according to the scripting language runtime environment version number corresponding to the target scripting language runtime environment version;

[0159] The access path of the target folder and the corresponding scripting language runtime environment version number are stored in a pre-created configuration file.

[0160] According to one or more embodiments of this disclosure, [Example 3] provides the method of Example 1, which further includes, before launching the target scripting language runtime environment version as a subprocess via a pre-generated launcher to run the corresponding scripting language file via the target scripting language runtime environment version:

[0161] Store at least two pre-created launchers in a preset folder.

[0162] According to one or more embodiments of this disclosure, [Example 4] provides the method of Example 1, which further includes, before launching the target scripting language runtime environment version as a subprocess via a pre-generated launcher to run the corresponding scripting language file via the target scripting language runtime environment version:

[0163] Read at least one command-line script from the installation directory of each pre-scanned scripting language runtime environment;

[0164] Scan the corresponding script language file path in each command-line script;

[0165] The correspondence between the target commands and the script language files is stored in the corresponding configuration file;

[0166] Create the launcher corresponding to the target command.

[0167] According to one or more embodiments of this disclosure, [Example 5] provides the method of Examples 1-4, wherein determining the target scripting language runtime environment version corresponding to each terminal session under the current operating system includes:

[0168] Get the environment variables of the parent process or terminal session under the current operating system;

[0169] The target scripting language runtime environment version corresponding to the terminal session is determined based on the environment variables.

[0170] According to one or more embodiments of this disclosure, [Example 6] provides the method of Examples 1-4, wherein determining the target scripting language runtime environment version corresponding to each terminal session under the current operating system includes:

[0171] The target scripting language runtime environment version corresponding to the terminal session is determined based on the pre-stored configuration file.

[0172] According to one or more embodiments of this disclosure, [Example 7] provides the methods of Examples 1-4, wherein the script language file of the target script language runtime environment version is launched as a subprocess via a pre-generated launcher, comprising:

[0173] If the target command is a first type command, the executable file in the scripting language runtime environment installation directory where the target scripting language runtime environment version is located is launched directly as a child process through the launcher;

[0174] If the target command is a second type of command, the launcher obtains and reads the target scripting language runtime environment version and the location of the scripting language file corresponding to the target command, and executes the scripting language file in the form of a subprocess through the scripting language runtime environment.

[0175] According to one or more embodiments of this disclosure, [Example 8] provides the method of Example 2, wherein the attribute information includes: scripting language runtime environment version number, processor architecture, and whether it is a Long Term Support (LTS) system.

[0176] According to one or more embodiments of this disclosure, [Example 9] provides the methods of Examples 1-4, wherein the target scripting language runtime environment version includes at least the following parameters: scripting language runtime environment version number and processor architecture.

[0177] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this disclosure can be achieved, and this is not limited herein.

[0178] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A method of running a script language file, characterized by, include: In response to the operation of executing commands on at least two terminal sessions at the same time, determine the target scripting language runtime environment version corresponding to each terminal session under the current operating system; The target scripting language runtime environment version is launched as a subprocess using a pre-generated launcher, so that the corresponding scripting language file can be run using the target scripting language runtime environment version; Before launching the target scripting language runtime environment version as a subprocess via a pre-generated launcher to run the corresponding scripting language file using the target scripting language runtime environment version, the method further includes: Store at least two pre-created launchers in a preset folder.

2. The method of claim 1, wherein, Before launching the target scripting language runtime environment version as a subprocess via a pre-generated launcher to run the corresponding scripting language file using the target scripting language runtime environment version, the method further includes: Obtain the compressed package of the scripting language runtime environment version release corresponding to the target scripting language runtime environment version; Extract the compressed package of the scripting language runtime environment version to the pre-created target folder; The access path of the target folder and the corresponding scripting language runtime environment version number are stored in a pre-created configuration file.

3. The method of claim 1, wherein, Before launching the target scripting language runtime environment version as a subprocess via a pre-generated launcher to run the corresponding scripting language file using the target scripting language runtime environment version, the method further includes: Read at least one command-line script from the installation directory of each pre-scanned scripting language runtime environment; Scan the corresponding script language file path in each command-line script; The mapping between the target command and the script language file path is stored in the corresponding configuration file; wherein, the target command is the command corresponding to the command line script; Create the launcher corresponding to the target command.

4. The method according to any of claims 1 to 3, characterized in that, The step of determining the target scripting language runtime environment version corresponding to each terminal session under the current operating system includes: Get the environment variables of the parent process or terminal session under the current operating system; The target scripting language runtime environment version corresponding to the terminal session is determined based on the environment variables.

5. The method according to any of claims 1 to 3, characterized in that The step of determining the target scripting language runtime environment version corresponding to each terminal session under the current operating system includes: The target scripting language runtime environment version corresponding to the terminal session is determined based on the pre-stored configuration file.

6. The method according to any one of claims 1 to 3, characterized in that, The step of launching the target scripting language runtime environment version as a subprocess via a pre-generated launcher, so as to run the corresponding scripting language file through the target scripting language runtime environment version, includes: If the target command is a first type command, the executable file in the scripting language runtime environment installation directory where the target scripting language runtime environment version is located is launched directly as a child process through the launcher. If the target command is a second type of command, the launcher obtains and reads the version of the target scripting language runtime environment and the location of the scripting language file corresponding to the target command, and executes the scripting language file in the form of a subprocess through the scripting language runtime environment; the target command is the command corresponding to a command-line script.

7. The method of claim 2, wherein, The attribute information of the scripting language file includes: the scripting language runtime environment version number, the processor architecture, and whether it is supported by Long Term Support (LTS).

8. The method according to any one of claims 1-4, characterized in that, The target scripting language runtime environment version includes at least the following parameters: scripting language runtime environment version number and processor architecture.

9. An apparatus for running a script language file, characterized by comprising: include: The determination module is used to determine the target scripting language runtime environment version corresponding to each terminal session under the current operating system in response to the operation of executing commands on at least two terminal sessions at the same time. The startup module is used to launch the target scripting language runtime environment version as a subprocess through a pre-generated launcher, so as to run the corresponding scripting language file through the target scripting language runtime environment version; The second storage module is used to store at least two pre-created launchers in a preset folder before the target scripting language runtime environment version is launched as a subprocess through the pre-generated launcher to run the corresponding scripting language file through the target scripting language runtime environment version.

10. An electronic device, comprising: The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the method for running the script language file according to any one of claims 1-8.

11. A computer readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that are used to cause a processor to execute the method of running the script language file according to any one of claims 1-8.

12. A computer program product, characterised in that, The computer program product includes a computer program that, when executed by a processor, implements the method for running a script language file according to any one of claims 1-8.